hdu 4379The More The Better
来源:互联网 发布:北 north plus新域名 编辑:程序博客网 时间:2024/05/17 23:12
在前一天的多校训练中只有一点点的思路,但是忘了用__int64,只是用int结果一直是wrong,就弃疗了,今天看了其他大神的题解豁然开朗。
因为题目的要求是从x[ ]数组中选出m个元素(m要最大),组成y[ ],y[ ]中的任何一个必须小于等于L还有任意两个相加的和必须小于等于L,所以只要将小于等于L/2的数全部取出放入y中,然后再判断最大的被选中的元素值和最小的未被选中的元素值是否比L小,若是m++;输出m的值
代码:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <stack>
using namespace std;
int main() {
__int64 n,L,A,B,mod;
while(~scanf("%I64d%I64d%I64d%I64d%I64d",&n,&L,&A,&B,&mod)) {
__int64 mid=L/2;
__int64 k=1;
__int64 MAX=-1;
int m=0;
__int64 MIN=2000000001;
for(__int64 i=1; i<=n; i++) {
__int64 temp=(A*i+B)%mod;
if(temp<=mid) {
m++;
if(temp>MAX) {
MAX=temp;
}
} else {
if(temp<MIN) {
MIN=temp;
}
}
}
if(MAX+MIN<=L) {
m++;
}
printf("%d\n",m);
}
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
- uva 815 - Flooded!(点名要做的思路题~我觉得方法挺好)
- 开源夏令营《基于HackRF开发GPS信号仿真模拟器》工作总结(二)
- Linux下socket最大连接数 ulimit -n 最大值修改
- 关于arcmap的VBA不能使用解决办法
- Activity正真的活动生存期
- hdu 4379The More The Better
- scp无密码传输
- 黑马程序员---技术博客日记(1)
- 使用集成的ADT bundle来搭建android开发环境
- poj 2352 Stars
- 编程算法 - 堆(heap) 代码(C)
- 黑马程序员-----@property和@synthesize
- windows 2008r2 安装 oracle11gr2 dataguard总结
- 排序算法-冒泡、插入、归并、希尔、快速、选择--代码总结