上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 27 下一页
摘要: 刚开始看到这题的时候,理解错了数据范围,以为K<100,那就是道高精度水题了,于是用java打了交,runtime error!然后就想出了这么个模拟的方法,直接用一个数组存下fibonacci表示的数,两个数合并在一起以后,就是处理这个数组的问题了,其实也不难,也就是如果存在两个相邻的,如a,a+1,就把它们合并成a+2,还有就是如果有两个a,则分成a-2和a+1。/* * hdu3818cpp/win.cpp * Created on: 2012-10-28 * Author : ben */#include <cstdio>#include <cstdlib> 阅读全文
posted @ 2012-10-28 22:54 moonbay 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 挺简单,直接上代码。/* * hdu2062/win.cpp * Created on: 2012-10-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#include <map> 阅读全文
posted @ 2012-10-28 12:40 moonbay 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 就是建图,把题目描述的东东转换成一张图求最短路就行了,因为是随机询问,所以用floyd比较方便。不过打完之后一直WA,百思不得其解的情况下看了一下discuss,有人说得用long long,于是我马上改了交,果然过了……唉,以后看题还是得细心……/* * hdu1690/win.cpp * Created on: 2012-10-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime&g 阅读全文
posted @ 2012-10-27 21:17 moonbay 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 这题还是挺不错的,第一个突破点就是n很大但是m很小,所以能组成的集合最多有2^14种的,枚举这每一种能否构成即可。刚开始的时候是用set存每一个数的,超时,略加改进,用位存储就过掉了。不过我还是算蹭过的,600多ms,应该还能继续用位运算优化。/* * hdu3306/win.cpp * Created on: 2012-10-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime> 阅读全文
posted @ 2012-10-27 14:23 moonbay 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 刚看的时候还以为挺难的,试了一下最水的方法,居然过了。就是从N以后往下试,试到smith数停止就行,而且对于smith数的判断也可以简单处理,循环到sqrt(n)即可,唉,这种简单方法我这次现场赛咋没想到呢……/* * hdu1333/win.cpp * Created on: 2012-10-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iost 阅读全文
posted @ 2012-10-27 12:27 moonbay 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 这题第一个突破点是:由于第i个城市建加油站需2^(i-1),这比前i-1个城市都建加油站耗费的还多,所以可以倒过来枚举,如果前n-1城市都建加油站而第n个城市不建能满足要求的话,那么最终结果肯定是不需要在n建加油站的,否则就需要建;接下来继续考虑在这种情况下前n-2个城市全建、n-1不建是否能满足要求,进而确定n-1城市的状态。依此类推,就能用O(N)的时间确定每一个城市是否建站的状态。对于一个确定的状态,用广搜进行判断即可,不过细节还是挺多的,例如有些城市(不建加油站)可以从加油站过去,但是无法再次回到加油站。比赛的时候代码不是我打的,也没有打印带回来,现在懒得再打一次贴上来了,有时间再说吧 阅读全文
posted @ 2012-10-26 23:28 moonbay 阅读(720) 评论(0) 推荐(0) 编辑
摘要: 枚举r,二分K就可以了,不过还是需要注意细节,比较数据类型之类的,不然容易错。/* * hdu4430/win.cpp * Created on: 2012-10-26 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include & 阅读全文
posted @ 2012-10-26 23:01 moonbay 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目还是挺简单的,就是硬算,先求出N的所有因数,然后一个个地加起来,最后再处理输出就行了。现场赛的时候,模板准备不足,这题居然打了一个多小时,唉,要是能早交20分钟,银牌就妥妥的了……杯具……/* * hdu4432/win.cpp * Created on: 2012-10-26 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream># 阅读全文
posted @ 2012-10-26 15:51 moonbay 阅读(374) 评论(0) 推荐(0) 编辑
摘要: 暴搜就可以过了,简单。/* * hdu2181/win.cpp * Created on: 2012-10-25 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#include <map&g 阅读全文
posted @ 2012-10-26 10:55 moonbay 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 比较简单的计算几何,首先枚举两个在圆上的点,然后数一数多少个点在此圆上,复杂度n^3。但是要注意的是如果这样得到的结果是0,那么还是要输出1,因为至少可以捞一条鱼,这是一个易错点!/* * hdu1077/win.cpp * Created on: 2012-10-25 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#includ 阅读全文
posted @ 2012-10-25 21:48 moonbay 阅读(222) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 27 下一页