POJ-3484-Showstopper
来源:互联网 发布:淘宝联盟拍了却没订单 编辑:程序博客网 时间:2024/06/05 18:40
继续二分,注意都用long long吧
代码:
#include<cstdio>#include<cstring>#include<iostream>using namespace std;const long long inf=1LL<<35;const long long maxn=1e6+100;char str[110];long long x[maxn],y[maxn],z[maxn],cnt;long long Sum(long long val){ long long sum=0; for(int i=0;i<cnt;i++) { if(val<x[i]) continue; sum+=(min(val,y[i])-x[i])/z[i]+1; } return sum;}void solve(){ long long l=1,r=inf,ans=-1; while(l<=r) { long long mid=(l+r)>>1; if(Sum(mid)&1) { r=mid-1; ans=mid; } else l=mid+1; } if(ans==-1) { printf("no corruption\n"); return; } printf("%I64d %I64d\n",ans,Sum(ans)-Sum(ans-1));}int main(){ cnt=0; while(gets(str)!=NULL) { if(strlen(str)==0) { if(cnt==0) continue; solve(); cnt=0; } else { sscanf(str,"%I64d%I64d%I64d",&x[cnt],&y[cnt],&z[cnt]); cnt++; } } if(cnt) solve(); return 0;}
0 0
- Showstopper - POJ 3484 二分
- POJ 3484 Showstopper
- POJ 3484 Showstopper 二分
- POJ-3484-Showstopper
- Showstopper - POJ 3484 二分
- POJ 3484 - Showstopper(二分搜索)
- POJ - 3484 Showstopper 二分搜索
- POJ 3484 Showstopper 已翻译
- poj 3484 Showstopper(二分)
- POJ 3484 Showstopper (二分搜索)
- POJ - 3484 Showstopper(二分 + 前缀和)
- POJ3484-Showstopper
- poj3484 Showstopper 二分
- POJ3484 Showstopper(二分)
- 【BZOJ1243】[Seerc2007]Showstopper【二分】
- Showstopper:观止——微软创建NT和未来的夺命狂奔
- POJ
- poj
- TOJ 1154. A Mathematical Curiosity
- brctl 配置网桥
- 进程间通信---IPC对象 之 消息队列
- poj 3057 Evacuation
- hdu 4946 Area of Mushroom
- POJ-3484-Showstopper
- 内存的释放问题
- 【OpenMesh】Halfedge数据结构
- [2125]串结构练习——字符串匹配 sdutOJ
- 计算几何
- Mac OS X中安装vtk时的错误解决
- HDU4939 Stupid Tower Defense (DP)
- mysql存储引擎介绍
- java oracle thin 和 oci 连接方式实现多数据库的故障切换