POJ 1064 Cable master
来源:互联网 发布:章亮算法 编辑:程序博客网 时间:2024/05/03 05:03
二分答案
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>using namespace std;int a[10010];int main(){#ifndef ONLINE_JUDGE freopen("a.in","r",stdin); freopen("a.out","w",stdout);#endif int n,k; while(cin>>n>>k){ long long cnt=0; int maxl=0; for(int i=0;i<n;i++){ //之前的输入时这样写的。。 //char s[5]; //cin>>s; //a[i]=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0'); int b; scanf("%d.%d",a+i,&b); a[i]=a[i]*100+b; cnt+=a[i]; maxl=max(maxl,a[i]); } if(cnt<k){ cout<<"0.00"<<endl; continue; } int s=1,t=maxl; int ans=1; while(t>=s){ int mid=(s+t)/2; long long sum=0; for(int i=0;i<n;i++) sum+=a[i]/mid; if(sum>=k){ s=mid+1; if(mid>ans) ans=mid; } else t=mid-1; } printf("%.2f\n",ans*0.01); } return 0;}
- poj 1064 Cable master
- poj 1064 Cable master
- poj 1064 Cable master
- POJ 1064 Cable master
- poj 1064 Cable master
- POJ-1064-Cable master
- poj 1064--Cable master
- POJ 1064 Cable master
- POJ 1064 Cable master
- poj 1064 Cable master
- poj 1064 Cable master
- POJ(1064)cable master
- POJ 1064 Cable master
- cable master POJ 1064
- POJ 1064 Cable master
- POJ 1064 Cable Master
- POJ-1064 Cable master
- POJ 1064 Cable master
- [linux]I/O端口分配request_region()
- 关于ListView顶部和底部滚(拖)动出现阴影解决方案
- jax-rpc、jax-ws和 axis、xfire的联系和区别
- 关于自己应用内的流量监控
- 使android中圆角图片拉伸不变形的方法
- POJ 1064 Cable master
- 输出字母三角形
- div+css命名规则-增强SEO
- GPU Cuda编程学习过程中遇到的几个重要概念
- eclipse设置执行前保存文件
- 动态规划-矩阵链乘
- 求两个数的最大公约数
- 对引用型参数是否加const限定一定要慎重
- div居中的方法