Teenits 2008-3-22 20:51
南理工ACM选拔赛07年的题目
//这是第一题,完整的是六道题目,在附件里,最多有人做出了3道,比赛时间是3小时,今年是5小时! An unual set is defined as that if a and b are in the set, a+b+a*b is in the set too. For example, if it's defined that 2 and 3 are in the set, 11 (2+3+2*3) is in the set and so on. Now, Allen has his problem with the unual set. He wants to know that if that if it's defined that 1 and 2 are in the set, how about some other integer? Your program is to read a series of input lines. Each input line will have a single integer on it, that will be from 1 to 2^30. For each integer read, if the integer is in the unual set give the answer "1". Else, please output "0". [color=#0070e8]Input[/color]The input consists of a series of single integer, one per line. The integer is in the range of 1 to 2^30. The input will be terminated by end-of-file. [color=#0070e8]Output[/color]The output is a "0" if the input integer is not in the set, else print "1". There is one line of output for each input line. [color=#0070e8]Sample Input[/color]5 17 18 [color=#0070e8]Sample Output[/color]1 1 0
无忧 2008-4-1 23:08
第一题解答
c=a+b+a*b
c+1 = (a+1)*(b+1)
这样便可以看出,如果一个元素是在这个集合里只要看这个元素c是否满足c+1=2^m*3^n(m=1...k,n=1,k)
这个k<30
Teenits 2008-4-17 12:36
第一题是最简单的
可能是怕有些参赛者一题都做不出来,伤自尊。。。