摘要: 8球胜负(eight)Description8球是一种台球竞赛的规则。台面上有7个红球、7个黄球以及一个黑球,当然还有一个白球。对于本题,我们使用如下的简化规则:红、黄两名选手轮流用白球击打各自颜色的球,如果将该颜色的7个球全部打进,则这名选手可以打黑球,如果打进则算他胜。如果在打进自己颜色的所有球之前就把黑球打进,则算输。如果选手不慎打进了对手的球,入球依然有效。现在给出打进的球(白球除外)的顺序,以及黑球由哪方打进,你的任务是判定哪方是胜者。假设不会有一杆同时打进一颗黑球和其他彩球。Input输入包含多组数据。每组数据第一行是一个整数N(1<=N<=15),表示打进的球的个数, 阅读全文
posted @ 2011-04-14 23:04 cpoint 阅读(921) 评论(0) 推荐(0) 编辑
摘要: The 3n+ 1 problemBackgroundProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs.The ProblemConsider t 阅读全文
posted @ 2011-04-13 23:01 cpoint 阅读(248) 评论(0) 推荐(0) 编辑
摘要: #include<time.h>clock_tstart,end;doubleduration;start=clock();//dosomethingend=clock();duration=(double)(end-start)/CLOCKS_PER_SEC;//秒 阅读全文
posted @ 2011-04-13 22:44 cpoint 阅读(496) 评论(0) 推荐(0) 编辑
摘要: 汉字统计Problem Description统计给定文本文件中汉字的个数。Input输入文件首先包含一个整数n,表示测试实例的个数,然后是n段文本。Output对于每一段文本,输出其中的汉字的个数,每个测试实例的输出占一行。[Hint:]从汉字机内码的特点考虑~Sample Input2 WaHaHa! WaHaHa! 今年过节不说话要说只说普通话WaHaHa! WaHaHa! 马上就要期末考试了Are you ready?Sample Output14 9AC code:#include<stdio.h>#include<math.h>#include<cty 阅读全文
posted @ 2011-04-13 22:35 cpoint 阅读(491) 评论(0) 推荐(0) 编辑
摘要: 人见人爱A-BProblem Description参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算。(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)呵呵,很简单吧?Input每组输入数据占1行,每行数据的开始是2个整数n(0<=n<=100)和m(0<=m<=100),分别表示集合A和集合B的元素个数,然后紧跟着n+m个元素,前面n个元素属于集合A,其余的属于集合B. 每个元素为不超出int范围的整数,元素之间有 阅读全文
posted @ 2011-04-13 22:26 cpoint 阅读(690) 评论(0) 推荐(0) 编辑
摘要: 整除的尾数Problem Description一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么呢?Input输入数据有若干组,每组数据包含二个整数a,b(0<a<10000, 10<b<100),若遇到0 0则处理结束。Output对应每组数据,将满足条件的所有尾数在一行内输出,格式见样本输出。同组数据的输出,其每个尾数之间空一格,行末没有空格。Sample Input200 401992 950 0Sample Output00 40 8015AC code:#include<stdio.h>intmain(){inta 阅读全文
posted @ 2011-04-13 22:16 cpoint 阅读(777) 评论(1) 推荐(0) 编辑
摘要: 绝对值排序Problem Description输入n(n<=100)个整数,按照绝对值从大到小排序后输出。题目保证对于每一个测试实例,所有的数的绝对值都不相等。Input输入数据有多组,每组占一行,每行的第一个数字为n,接着是n个整数,n=0表示输入数据的结束,不做处理。Output对于每个测试实例,输出排序后的结果,两个数之间用一个空格隔开。每个测试实例占一行。Sample Input3 3 -4 24 0 1 2 -30Sample Output-4 3 2-3 2 1 0AC code:#include<stdio.h>#include<math.h>#i 阅读全文
posted @ 2011-04-13 22:05 cpoint 阅读(597) 评论(0) 推荐(0) 编辑
摘要: 第几天?Problem Description给定一个日期,输出这个日期是该年的第几天。Input输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。Output对于每组输入数据,输出一行,表示该日期是该年的第几天。Sample Input1985/1/202006/3/12Sample Output2071AC code:#include<stdio.h>#include<math.h>intisleapyear(inty){if(((y%4==0)&&(y%10 阅读全文
posted @ 2011-04-13 22:00 cpoint 阅读(569) 评论(0) 推荐(0) 编辑
摘要: ASCII码排序Problem Description输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。Input输入数据有多组,每组占一行,有三个字符组成,之间无空格。Output对于每组输入数据,输出一行,字符中间用一个空格分开。Sample InputqweasdzxcSample Outpute q wa d sc x zAC code:#include<stdio.h>#include<string.h>#defineN3voidswap(char*a,char*b){chartemp;temp=*a;*a=*b;*b=temp;}voids 阅读全文
posted @ 2011-04-13 21:54 cpoint 阅读(1319) 评论(0) 推荐(0) 编辑
摘要: Climbing WormProblem DescriptionAn inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting then repeats. How long before 阅读全文
posted @ 2011-04-13 21:41 cpoint 阅读(472) 评论(0) 推荐(0) 编辑
浏览次数:travelocity promotion codes