华南师范大学ACM初赛题

合集下载

acm数学竞赛试题

acm数学竞赛试题

acm数学竞赛试题
ACM数学竞赛试题通常涉及各种数学领域,包括但不限于代数、几何、概率统计和组合数学等。

以下是一些经典的ACM数学竞赛试题:
1. 平面上n个点的k距离和最小值问题:给定平面上n个点,对于每个点,计算它到其他所有点的距离,然后求出这些距离中的k个最小值。

问题是:如何有效地计算这k个最小值?
2.最长公共子序列问题:给定两个序列,找出它们的最长公共子序列。

例如,对于序列
A = [1, 2, 3, 4] 和
B = [2, 3, 4, 5],最长公共子序列是[2, 3, 4]。

3. 凸包问题:给定平面上的一组点,找到一个最小的凸多边形,使得这个多边形能够包含这组点中的所有点。

4. 最短路问题:给定一个有向图,其中每条边都有一个非负的权重,找出图中任意两点之间的最短路径。

5. 子集和问题:给定一个正整数数组和一个目标值,判断数组中是否存在和为目标值的两个非空子集。

例如,给定数组[1, 2, 3, 4] 和目标值7,判断是否存在两个子集,它们的和分别为7。

以上只是ACM数学竞赛试题的一部分,实际上还有更多涉及数学各个领域的题目。

要提高解决这类问题的能力,需要不断练习和研究。

acm初赛试题及答案

acm初赛试题及答案

acm初赛试题及答案# acm初赛试题及答案1. 问题描述给定一个整数n,求出n以内所有正整数的和。

2. 输入格式输入包含一个整数n(1≤n≤10000)。

3. 输出格式输出一个整数,表示n以内所有正整数的和。

4. 样例输入```100```5. 样例输出```5050```6. 问题分析本题要求计算从1到n的所有正整数的和。

这是一个简单的数学问题,可以通过公式求解。

7. 解题思路使用求和公式:\( \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \)。

8. 算法实现编写一个函数,输入n,输出计算结果。

9. 代码示例```pythondef sum_of_numbers(n):return n * (n + 1) // 2n = int(input())print(sum_of_numbers(n))```10. 注意事项输入的n可能会非常大,需要考虑整数溢出的问题。

11. 测试用例- 输入:1输出:1- 输入:10输出:55- 输入:10000输出:5000500012. 评分标准- 正确性:算法正确,输出结果符合预期。

- 效率:算法执行效率高,能在规定时间内完成计算。

- 代码风格:代码可读性好,注释清晰。

13. 常见错误- 未考虑整数溢出。

- 未正确使用求和公式。

- 代码中存在语法错误。

14. 扩展思考- 如果要求计算从m到n的所有正整数的和,应该如何修改算法? - 如何优化算法以处理更大的输入值?15. 参考答案- 对于扩展思考的第一个问题,可以将求和公式修改为:\( \sum_{i=m}^{n} i = \frac{n(n+1)}{2} - \frac{(m-1)m}{2} \)。

- 对于扩展思考的第二个问题,可以考虑使用更高效的数据结构或者算法来减少计算量。

以上是ACM初赛试题及答案的完整内容。

acm程序设计大赛试题

acm程序设计大赛试题

acm程序设计大赛试题ACM(Association for Computing Machinery)程序设计大赛是一项面向大学生的编程竞赛,旨在提高参赛者在算法和数据结构方面的能力。

每年都会举办多个级别的比赛,包括区域赛、国家赛和世界总决赛。

ACM程序设计大赛试题通常涵盖广泛的计算机科学和编程知识,包括但不限于以下几个方面:1. 算法和数据结构,试题可能涉及各种经典算法和数据结构的应用,如排序、查找、图论、动态规划、贪心算法等。

参赛者需要能够理解这些算法的原理和实现方法,并能够根据问题的要求选择合适的算法进行解题。

2. 编程语言和编程技巧,参赛者需要熟练掌握至少一种编程语言,通常是C++、Java或Python。

他们需要能够使用该语言进行编程,实现算法和数据结构的代码,并能够处理输入输出、异常处理等编程任务。

此外,熟练掌握一些编程技巧,如优化算法、调试代码等也是非常重要的。

3. 数学和逻辑思维,ACM程序设计大赛试题可能涉及一些数学和逻辑问题,如数论、组合数学、概率统计等。

参赛者需要具备基本的数学知识,并能够将其应用到解题过程中。

4. 实际问题的建模和解决,ACM程序设计大赛试题通常基于实际问题,参赛者需要能够将问题抽象为计算机可解决的形式,并设计出高效的算法和数据结构进行求解。

这需要参赛者具备一定的问题建模和解决能力。

5. 时间和空间复杂度分析,参赛者在解决问题时需要考虑算法的时间和空间复杂度。

他们需要能够分析算法的运行时间和所需内存,并根据比赛规则和问题要求选择合适的算法以保证程序的效率。

总的来说,ACM程序设计大赛试题要求参赛者具备扎实的计算机科学和编程基础,能够独立思考和解决复杂的问题。

参赛者需要在规定的时间内完成试题,并保证程序的正确性和效率。

通过参加ACM程序设计大赛,参赛者能够提升自己的编程能力和解决问题的能力,同时也能够与其他优秀的程序员交流和学习。

acm试题及答案2

acm试题及答案2

acm试题及答案2ACM试题及答案21. 问题描述:编写一个程序,计算给定整数序列中的最大子段和。

2. 输入格式:第一行包含一个整数N,表示序列的长度。

第二行包含N个整数,表示序列中的整数。

3. 输出格式:输出一个整数,表示序列中的最大子段和。

4. 样例输入:```51 -2 -34 -1```5. 样例输出:```6```6. 问题分析:该问题可以通过动态规划的方法来解决。

定义一个数组dp,其中dp[i]表示以第i个元素结尾的最大子段和。

状态转移方程为dp[i] = max(dp[i-1] + nums[i], nums[i])。

7. 算法实现:```pythondef maxSubArray(nums):n = len(nums)dp = [0] * ndp[0] = nums[0]max_sum = nums[0]for i in range(1, n):dp[i] = max(dp[i-1] + nums[i], nums[i])max_sum = max(max_sum, dp[i])return max_sum```8. 复杂度分析:时间复杂度为O(n),其中n为序列的长度。

空间复杂度为O(n)。

9. 测试用例:- 输入:`[3, -2, 4]`输出:`5`- 输入:`[-2, 1, -3, 4, -1, 2, 1, -5, 4]`输出:`6`10. 注意事项:- 确保输入的序列长度N大于等于1。

- 序列中的整数可以是负数或正数。

- 输出结果应该是一个整数。

11. 扩展思考:- 如何优化算法以减少空间复杂度?- 如果序列中的整数是浮点数,算法是否仍然有效?12. 参考答案:- 可以通过只使用一个变量来存储最大子段和,以及一个变量来存储当前子段和,从而将空间复杂度优化到O(1)。

- 如果序列中的整数是浮点数,算法仍然有效,但需要注意浮点数运算的精度问题。

acm编程比赛入门题目集

acm编程比赛入门题目集

程序设计比赛试题主办方:迅翔计算机协会最少钱币数:【问题描述】这是一个古老而又经典的问题。

用给定的几种钱币凑成某个钱数,一般而言有多种方式。

例如:给定了6种钱币面值为2、5、10、20、50、100,用来凑15元,可以用5个2元、1个5元,或者3个5元,或者1个5元、1个10元,等等。

显然,最少需要2个钱币才能凑成15元。

你的任务就是,给定若干个互不相同的钱币面值,编程计算,最少需要多少个钱币才能凑成某个给出的钱数。

【要求】【数据输入】输入可以有多个测试用例。

每个测试用例的第一行是待凑的钱数值M(1 <= M <= 2000,整数),接着的一行中,第一个整数K(1 <= K <= 10)表示币种个数,随后是K 个互不相同的钱币面值Ki(1 <= Ki <= 1000)。

输入M=0时结束。

【数据输出】每个测试用例输出一行,即凑成钱数值M最少需要的钱币个数。

如果凑钱失败,输出“Impossible”。

你可以假设,每种待凑钱币的数量是无限多的。

【样例输入】156 2 5 10 20 50 10011 2【样例输出】2ImpossibleFeli 的生日礼物【问题描述】Felicia 的生日是11月1日(和Kitty是同一天生的哦)。

于是Feli请来Kitty一起过生日。

Kitty带来了最新款的“Kitty猫”玩具准备送给Feli,不过她说,这份礼物可不是白送的。

Feli要帮她一个忙,才能够得到心仪已久的玩具。

Kitty说,“Kitty猫”玩具已经卖出了n!个,n<=10^100 *_*,Kitty想知道确切的数字,而不是无聊的“一个数加个感叹号”。

Feli 听了大吃一惊。

要知道,算出n!是一个无比艰巨的任务。

Feli告诉Kitty,就算Feli算出n!,Kitty也看不下去,因为当n=20 时,计算机的长整型已经存不下了(Kitty只能接受1-9之间的数字)。

ACM试题及参考答案

ACM试题及参考答案

1. 给定一个矩阵M(X, Y),列集为X ,行集为Y 。

如果存在对其列的一个排序,使得每一行的元素都严格递增,称M 是一个次序保持矩阵。

例如下图中存在一个排序x 4,x 1,x 2,x 3,x 5I ⊆X ,满足:子矩阵M(I,Y)是次序保持矩阵。

[测试数据] 矩阵M :[测试数据结果] I={ x 1,x 3,x 4,x 7,x 8}[解题思路] 将该问题归约为在一个有向图中找一条最长路径的问题。

给定矩阵M=(a ij ),行集Y ,列集X ,行子集J ⊆Y ,定义有向图D A =(V A ,E A ),其中V A 含有|X|个顶点,每个顶点代表X 中的一列,如果顶点u ,v 对应的列x u ,x v 满足,对于任意的j ∈J ,u v ij ij a a <,则有一条从u 到v 的弧(u ,v )∈E 。

显然,D A 是个无环图,可以在O(|X|2)时间内构造完毕。

对于任意的条件子集J ,A(I,J)是次序保持的当且仅当对应于J 中条件的顶点在D A 中构成一条有向路径。

从而我们只需在有向图D A 中找一条最长路径,该问题可在O(|V A |+| E A |)时间内完成。

按上面的方法构造有向图如下:有向图中找最长路径的线性时间算法。

一些表示方法如下:d out (u )为顶点u 的出度,d in (u )为顶点u 的入度,source 为入度为0的顶点,sink 为出度为0的顶点,N out (u )为u 指向的邻接点集合,P uv 为从u 到v 的最长路,显然应从source 到sink 。

在每一步为每个顶点关联一个永久的或临时的标签。

v被赋了一个临时标签(v’,i v)表明在当前步,算法找出的最长的从source到v的有向路长度为i v,且经由v’而来。

v被赋了一个永久标签[v’,i v]表明从source到v的最长有向路长度为i v,且经由v’而来,通过回溯每个顶点的永久标签就可以找出最长有向路。

ACM程序大赛选拔初赛试题 - 参考答案


《解方程》参考答案:
#include <stdio.h> #include <math.h> void main() {
int a,b,c,d; float x1,x2; scanf("%d %d %d %d",&a,&b,&c,&d); if(a==0) printf("x=%.2f",(float)(d-c)/b); else {
float dr=b*b-4*a*c; c-=d; if(dr>0) {
x1=(-b-sqrt(dr))/(2*a); x2=(-b+sqrt(dr))/(2*a); printf("x1=%.2f x2=%.2f\n",x1,x2); } if(dr==0) { x1=(-b+sqrt(dr))/(2*a); printf("x=%.2f\n",x1); } if(dr<0) printf("no answer\n"); } }
3、计算器 (难度系数:★★★☆☆)
题意:输入一个没有答案的算术式子,用计算机求出输出它的结果。 输入:一个字符串形如“a#b=”(#代表运算符号)。注意:输入的字符串中 a,b 代表的数 都为自然数。而且 a,b 的范围都是从 0 到 999。 输出:字符串对应的算式的答案。答案需保留两位有效数字。若无答案则输出“error” 示例:
输出:第1 行是选出顺序,第2 行是两名幸运儿的开始位置(按升序排列),位置编号之 间用一个空格分开。
示例:
输入(只选一组) 3 5 12
输出(幸运儿的位置)
2 13 241 53 2 4 6 8 10 12 3 7 11 5 19

ACM初步题及题解-推荐下载

装过程中以及安装结束后进行高中资料试卷调整试验;通电检查所有设备高中资料电试力卷保相护互装作置用调与试相技互术通关,1系电过,力管根保线据护敷生高设产中技工资术0艺料不高试仅中卷可资配以料置解试技决卷术吊要是顶求指层,机配对组置电在不气进规设行范备继高进电中行保资空护料载高试与中卷带资问负料题荷试22下卷,高总而中体且资配可料置保试时障卷,各调需类控要管试在路验最习;大题对限到设度位备内。进来在行确管调保路整机敷使组设其高过在中程正资1常料中工试,况卷要下安加与全强过,看2度并22工且22作尽22下可22都能2可地护1以缩关正小于常故管工障路作高高;中中对资资于料料继试试电卷卷保破连护坏接进范管行围口整,处核或理对者高定对中值某资,些料审异试核常卷与高弯校中扁对资度图料固纸试定,卷盒编工位写况置复进.杂行保设自护备动层与处防装理腐置,跨高尤接中其地资要线料避弯试免曲卷错半调误径试高标方中高案资等,料,编5试要写、卷求重电保技要气护术设设装交备备4置底高调、动。中试电作管资高气,线料中课并3敷试资件且、设卷料中拒管技试试调绝路术验卷试动敷中方技作设包案术,技含以来术线及避槽系免、统不管启必架动要等方高多案中项;资方对料式整试,套卷为启突解动然决过停高程机中中。语高因文中此电资,气料电课试力件卷高中电中管气资壁设料薄备试、进卷接行保口调护不试装严工置等作调问并试题且技,进术合行,理过要利关求用运电管行力线高保敷中护设资装技料置术试做。卷到线技准缆术确敷指灵设导活原。。则对对:于于在调差分试动线过保盒程护处中装,高置当中高不资中同料资电试料压卷试回技卷路术调交问试叉题技时,术,作是应为指采调发用试电金人机属员一隔,变板需压进要器行在组隔事在开前发处掌生理握内;图部同纸故一资障线料时槽、,内设需,备要强制进电造行回厂外路家部须出电同具源时高高切中中断资资习料料题试试电卷卷源试切,验除线报从缆告而敷与采设相用完关高毕技中,术资要资料进料试行,卷检并主查且要和了保检解护测现装处场置理设。备高中资料试卷布置情况与有关高中资料试卷电气系统接线等情况,然后根据规范与规程规定,制定设备调试高中资料试卷方案。

大学ACM考试题目及作业答案整理

ACM作业与答案整理1、平面分割方法:设有n条封闭曲线画在平面上,而任何两条封闭曲线恰好相交于两点,且任何三条封闭曲线不相交于同一点,问这些封闭曲线把平面分割成的区域个数。

#include <iostream.h>int f(int n){if(n==1) return 2;else return f(n-1)+2*(n-1);}void main(){int n;while(1){cin>>n;cout<<f(n)<<endl;}}2、LELE的RPG难题:有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.编程全部的满足要求的涂法.#include<iostream.h>int f(int n){if(n==1) return 3;else if(n==2) return 6;else return f(n-1)+f(n-2)*2;}void main(){int n;while(1){cin>>n;cout<<f(n)<<endl;}}3、北大ACM(1942)Paths on a GridTime Limit: 1000MS Memory Limit: 30000K DescriptionImagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered years ago (this time he's explaining that (a+b)2=a2+2ab+b2). So you decide to waste your time with drawing modern art instead.Fortunately you have a piece of squared paper and you choose a rectangle of size n*m on the paper. Let's call this rectangle together with the lines it contains a grid. Starting at the lower left corner of the grid, you move your pencil to the upper right corner, taking care that it stays on the lines and moves only to the right or up. The result is shown on the left:Really a masterpiece, isn't it? Repeating the procedure one more time, you arrive with the picture shown on the right. Now you wonder: how many different works of art can you produce?InputThe input contains several testcases. Each is specified by two unsigned 32-bit integers n and m, denoting the size of the rectangle. As you can observe, the number of lines of the corresponding grid is one more in each dimension. Input is terminated by n=m=0.OutputFor each test case output on a line the number of different art works that can be generated using the procedure described above. That is, how many paths are there on a grid where each step of the path consists of moving one unit to the right orone unit up? You may safely assume that this number fits into a 32-bit unsigned integer.Sample Input5 41 10 0Sample Output1262#include<iostream>using namespace std;long long f(long long m, long long n){if(n==0) return 1;else return f(m-1,n-1)*m/n;}int main(){long long m,n;while(scanf("%I64d %I64d",&n,&m) && n+m){printf("%I64d\n",f(m+n,min(m,n)));}return 0;}1、北大ACM(1012)JosephTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 31213 Accepted: 11700 DescriptionThe Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give us the message about the incident. For example when n = 6 and m = 5 then the people will be executed in the order 5, 4, 6, 2, 3 and 1 will be saved.Suppose that there are k good guys and k bad guys. In the circle the first k are good guys and the last k bad guys. You have to determine such minimal m that all the bad guys will be executed before the first good guy.题目大意:编号为1,2…, n的n个人排成一圈,从第一个人开始,去掉后面的第m个人,在从第m+1个人开始去掉后面第m个人,以此类推。

acm竞赛试题及答案

acm竞赛试题及答案ACM(Association for Computing Machinery)竞赛是一项全球性计算机科学竞赛,旨在锻炼参赛者的问题解决能力和编程技巧。

每年都有数千名来自不同学校的学生参加这一挑战。

本文将提供一些最近的ACM竞赛试题以及相应的答案,帮助读者了解和学习竞赛题目的类型和解题思路。

1. 问题描述给定一个由N个整数组成的数组A,请编写一个程序,找出数组中两个不同元素的差的最小值。

2. 输入格式- 第一行包含一个整数N,表示数组A的长度。

- 第二行包含N个以空格分隔的整数,表示数组A中的元素。

3. 输出格式输出一个整数,表示数组中两个不同元素的差的最小值。

4. 示例输入:51 52 9 12输出:15. 解题思路该问题可以通过对数组进行排序,并比较相邻两个数的差值来求解。

首先,将数组A进行升序排序。

然后,遍历排序后的数组,依次计算相邻两个数的差值,并记录其中的最小值。

最后,返回这个最小差值即可。

6. 代码实现```pythondef min_difference(nums):nums.sort() # 对数组进行升序排序min_diff = float('inf') # 初始化最小差值为正无穷大for i in range(len(nums)-1):diff = abs(nums[i] - nums[i+1]) # 计算相邻两个数的差值min_diff = min(min_diff, diff) # 更新最小差值return min_diff# 输入处理N = int(input())A = list(map(int, input().split()))# 调用函数并输出结果result = min_difference(A)print(result)```7. 答案解析对给定的数组进行排序后,遍历数组计算相邻两个数的差值,并记录其中的最小值。

上述代码中,首先将数组A进行升序排序,然后使用一个变量`min_diff`来记录最小差值。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

注意事项:1,题目一共有10个2,题目有严格的时间限制,请做好程序的优化3,题目采用标准读入,标准输出If the problem is a+b,Then the code is:C: #include <stdio.h>int main(void) {int a, b;while(scanf("%d%d", &a, &b)!=EOF)printf("%d", a + b);return 0;}C++: #include <iostream>using namespace std;int main(void) {int a, b;while(cin >> a >> b) cout << a + b;return 0;}Java : import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner in = new Scanner(System.in);int a = in.nextInt();int b = in.nextInt();System.out.println(a + b); } }4, 即时的排名和各队解题情况,可访问192.168.10.235/summary.html5, 比赛中不能使用电子设备,如U盘、手机等,一旦发现,立即取消比赛资格6, 登录PC^2,单击pc2team.bat ,用户名和密码皆为team***(***为你们队伍编号)Time Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionThe algorithm of matching String is based knowledge of ACMer,including Rabin-Karp, Knuth-Morris-Pratt , and AC automaton etc. Our Fat LYF has learned them in heart well , but “Transforming letters from Upper case to lower case,or lower case to Upper case, which depends on the letter given” this problem daunts him. As a smart programmer, you can solve it without doubt. InputMultiple test cases, for each case, you‟ve got only one letter as an input. Input terminated by EOF.OutputOutput one letter per line for each case.Sample InputaSample OutputATime Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionThis is a problem you can find easily in your C/C++ book. Given the lengths of three segments, if those segments could form a triangle, tell the square of the triangle , otherwise just output“Error”. InputMultiple test cases ,Three numbers a,b,c in Integer Type.(0<a,b,c<=108)OutputThe required square value(rounded to integer) or “Error”. Sample Input3 4 5Sample Output6Time Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionInputMultiple test cases , An integer n (1<n<104)OutputOne real number per line, rounded to810-.Sample Input1Sample Output2.66666667Time Limit: 2000 mSec Memory Limit : 65535 KB Problem DescriptionAs we all know, girls love necklaces, especially nice necklaces. Recently, LYF has fallen in love with a girl whose name is **; he wants to bring her a necklace as a gift. Now he has n colors, and the necklace is circular and it has n beads, LYF can use his colors to color the necklace. he wants to know how many different kinds of necklaces he can make,he may not use all the n colors. In this problem, the necklace is same when you rotate it around the center of the necklace or turn it over.InputFirst line is the test case T. Following T lines, each line is an integer n ( 1 ≤n ≤109 )OutputOutput the answer mod 20090531.Sample Input41234Sample Output131055Problem ETime Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionSir Wang is our drill master and our amicability .One day, Sir Wang cuts a string S into N pieces, s[1],……,s[N].Now, Wang Sir gives you these N sub-strings : s[1], ……,s[N]. There might be several possibilities that the string S could be. For example, if Dr Wang gives you three sub-strings {“a”,”ab”,”ac”}, the string S could be” aabac”,”aacab”,”abaac”,……Your task is to output the lexicographically smallest S.InputThe first line of the input is a positive integer T.T is the number of the test cases followed. The first line of each case is positive integer N (0<N<9) which represents the number of sub-strings.After that, N lines followed. The i-th line is the i-th sub-string s[i].Assume that the length of each sub-string is positive and less than 100.OutputThe output is each test is the lexicographically smallest S.No redundant spaces are needed.Sample Input13aabacSample OutputaabacProblem FTime Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionAs We have Known, Little LYF is daffy at MATHS and always crows about himself when chatting to others. All these things giving an incorrect impression to younger learners in CS & MA. One day, his ** want to test how clever he is , she gives him several formula like “variable1 relation variable2”,where relation may be <, <= , =, !=, >=,>,variables may contain up to 10 letters or digits and are case=sensitive. The task is to determine whether there is conflict.O(╯□╰)o Now ,he betrays himself with the strong feel of Tears and Penitence. O(∩_∩)O As a smart and compassionate programmer, pleases give him a strong hand.InputThere are several cases. Each case begins with a line “Case %n:” (%n is the case number),and contains several formulas, one per line. There are no more than 100 formulas for each case. Please see sample for more details. Input is terminated by EOF.OutputIf there is no conflict, output” YES”, otherwise, output” NO”. Please refer to sample output for the exact output format. Sample InputCase1:xyz<123123<45Case2:x<yy<xSample OutputCase1: YESCase2: NOImportant hintif a>b , b≥c, then a>c and a≥c is both regarded correct propositions.Problem GTime Limit: 2000 mSec Memory Limit : 65535 KB Problem DescriptionLYF is a lazy and smart boy in his words. So he is trying to develop an examine system under the directive book. He finds it not so easy to judge filling question. There may be multiple answers for a blank, For example, The 2008 Olympic games was hold in____City,The answer can be “Beijing”, and it can also be “Peking”, he made the answer like this: Beijing(Peking), which means that Beijing, Peking are both correct answers; A filling question may have several blanks, For some problems those blanks should be answered in order, for example, The 2000, 2004 Olympic games was hold respectively in ____City and ____City, The answer should be “Sydney Athens”; For other problems those blanks don‟t need be answered in order, for example, ACRush has taken part in the ICPC world finals in the year ____ and ____, The answer could be “2007|2009”, and it can also be “2009|2007”. Now you are required to help him to write a program to judge the filling problems.InputThe first line contains an integer N, indicate the number of problems. The following N*3 lines, each 3 lines indicate a filling problem, the first line is the question, the second line is the answer(There will not be a answer contains …|‟, ‟(…, ‟)‟ for every blank, For one problem every neighboring blanks are separated by “|” ), the third line indicate if the blanks should be filled in order, the word “True” means the blanks should be filled in order while “False” means that filling the blanks in order is not necessary. The following line contains an integer M, indicate the number of person, each person will fill all the problems, so there follows N*M lines, each N lines indicate a person‟s answer for the N problems (There will not be aa nswer contains …|‟, ‘(‟, …)‟ for every blank, For one problem every neighboring blanks are separated by “|” ), according to the sequence of the N problems.OutputThere are M lines, for each person, write the number of blankshe/she filled correctly.Sample Input3The 2004, 2008 Olympic Games was hold respectively in ____City and ____City.Athens|Beijing (Peking)TrueACRush has taken part in the ICPC world finals in the year ____ and ____.2007|2009FalseAaaa____bbbb_____.Ccc(cc)|Ddd(dd)False2Athens|Beijing2007|2009Dd|ccBeijing|Athens2009|2008Ddd|ccSample Output53Tips: For each question, any two of the blanks have different answers.Problem HTime Limit: 3000 mSec Memory Limit : 65535 KB Problem DescriptionSupernatural Cow LYF has developed a new kind of multi-core CPU, it works as follow. There are q (1 < q ≤50) identical cores in the CPU, and there are p (0 < p ≤200) jobs need to be done. Each job should run in some core and need only one unit time. The cores in the CPU can work simultaneously but each core can implement only one job at a time. When a job completed, it will incur a deferral cost. Job i has a deferral cost c(i, j) (0 ≤c(i, j) ≤1000000), where j is the completion time of the job (1 ≤j ≤p because any job done in the time later than p obviously not the optimal solution). Here we assume that c(i, j) is a monotonically no decreasing function of j. Now you are asked to find the schedule which have the minimum overall deferral cost.InputAn integer T indicated the number of test cases.For each test case: And Following is p lines, each line contain p integer, the jth integer of the ith line is the deferral cost c(i, j).OutputFor each test case, output a singer integer, which is the minimum total deferral cost of the Problem.Sample Input12 489 145 181 2694 86 158 16460 143 157 1654 45 109 207Sample Output254Hint;The idea of Cost-Flow is available.Problem ITime Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionA triangle is the most beautiful image in the world in LYF‟s mind. So please help to print a triangle with the Upper letters.InputMultiple test cases, one integer N (0<N<27)OutputA triangle of N lines in Upper letters.Sample Input3Sample OutputABBBCCCCCProblem JTime Limit: 1000 mSec Memory Limit : 65535 KB Problem DescriptionIn mathematics, a prime number is a whole number greater than 1 that cannot be divided exactly by any whole number except itself and the number 1, for example 23. Your task is to judge whether a integer is a prime number or not.InputOne Integer N (1< 1012)OutputIf N is Prime Number print“Yes”,Or Print “No”Sample Input3Sample OutputYesBiography:LYF is the president of our ACM club.He is a versatile boy , his song fascinates many girls , his action when playing badminton magnetizes many guys , and he is so handsome that nowhere he go , he can capture others‟ eyes.Just a fun .In fact , when he steps his fat foot in ACM / ICPC , he learns a lot and is high up in the pictures of the campus life .If you are students of level one or two, ACM/ICPC will be your best choice.ACM/ICPC is healthy, just do it.”。

相关文档
最新文档