论坛首页· 友情链接申请·申请版主· 广告投放· 道具中心· 设为首页· 收藏本站
发新话题
打印

南理工ACM选拔赛07年的题目

南理工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". InputThe 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. OutputThe 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. Sample Input5 17 18 Sample Output1 1 0
附件: 您所在的用户组无法下载或查看附件
回帖既是一种美德,是对作者的鼓励,同时又为后来者推荐了好文章,何乐而不为呢?

TOP

先得学好英文啊……
We keep on fighting till the end!

TOP

第一题解答

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

TOP

全E文
好好学习,天天向上!

TOP

回复 3# 的帖子

正解,太强了,数学方法才是王道

TOP

第一题是最简单的
可能是怕有些参赛者一题都做不出来,伤自尊。。。
回帖既是一种美德,是对作者的鼓励,同时又为后来者推荐了好文章,何乐而不为呢?

TOP

看看吧

TOP

发新话题