[统计] hdu 4379 the more the better
来源:互联网 发布:美式乡村风格知乎 编辑:程序博客网 时间:2024/06/06 09:51
/**[统计] 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
- HDU:4379 The More The Better
- hdu 4379The More The Better
- hdu-The more, The Better
- hdu The more, The Better
- hdu The more, The Better
- The more, The Better HDU
- The more, The Better HDU
- hdu——4379 ——The More The Better
- BNU OJ The More The Better || HDU 4379
- HDU 4379 The More The Better [坑爹想法题]
- hdoj(hdu)-1561-the more the better
- hdu 1561 The more,The better
- HDU 1516 The more, The Better
- hdu 1561 the more,the better
- python 调用smtplib输出重定向问题
- 网页特效大全
- IE浏览器内存泄露检测工具
- [博弈] hdu 4371 alice and bob
- linux 链表
- [统计] hdu 4379 the more the better
- lower_bound()返回值
- [DP] hdu 4374 One hundred layer #单调队列优化
- [数学] hdu 4377
- Game Analytics 101
- gdb调试多进程和多线程命令
- Android Map开发基础知识学习笔记
- winform 窗口移动
- upper_bound()返回值