[统计] hdu 4379 the more the better
2012-08-17 12:23
330 查看
/** [统计] hdu 4379 the more the better 数据都2 * 10^7了却只给4s的时间是要说明hdu服务器比较强大啊,好吧,O(n)的算法。 解题报告 from 人人hdoj 简单题,首先想到所有小于 L/2 的,统统可以放进来, 最后,按照题意,还可能可以放一个大于 L/2 的数进来, 当小于 L/2 的数里面的最大值加上这个大于 L/2 的数的和小于 L 时, 答案加一。最后要注意所有数都小于 L/2 的处理。O(n) 算法可过此题。 */ #include <stdio.h> #include <algorithm> using namespace std; int main() { __int64 low,hig; __int64 n,l,a,b,m,hh; while(scanf("%I64d%I64d%I64d%I64d%I64d",&n,&l,&a,&b,&m) == 5) { low = 0; hig = 10000000000LL; int res = 0; hh = l / 2; while(n--) { b = (b + a) % m; if(b <= hh) { ++res; low = max(low,b); } else { hig = min(hig,b); } } if(low + hig <= l) ++res; printf("%d\n",res); } return 0; }
相关文章推荐
- HDU 4379 The More The Better [枚举]
- HDU 4379 - The More The Better
- hdu——4379 ——The More The Better
- hdu 4379 The More The Better ( 2012 Multi-University Training Contest 8)
- HDU_4379_The More The Better
- HDU 4379 The More The Better [坑爹想法题]
- HDU 4379 The More The Better
- BNU OJ The More The Better || HDU 4379
- HDU 4379 The More The Better [坑爹想法题]
- hdu 4379 The More The Better
- hdu 4379 The More The Better 多校联合赛事第8场
- HDU:4379 The More The Better
- hdu 1561 the more the better (树形DP)
- hdoj(hdu)-1561-the more the better
- 【优化】HDU1856——The More The Better(顺便求解犇们JAVA版为啥不过)
- hdu 1856 More is better
- hdu 1856 More is better (究级版)
- HDU-1856 More is better
- HDU 1856~More is better~
- HDU-1856 More is better