| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
还真要用__int64,不明觉厉,求解答代码略挫,WA的不爽把int全换成__int64了,结果就A了 —————————————————————————————— #include <stdio.h> #include <math.h> #include <string.h> #define maxn 10010 __int64 num[maxn],n,k; __int64 count(__int64 m) { __int64 i,sum=0; for(i=0;i<n;i++) { sum+=num[i]/m; } return sum; } __int64 findx(__int64 left,__int64 right) { __int64 mid,res; while(left<=right) { mid=(left+right)/2; if(count(mid)>=k) { res=mid; left=mid+1; } else { right=mid-1; } } return res; } int main() { __int64 i,res,sum=0; double t; scanf("%I64d %I64d",&n,&k); for(i=0;i<n;i++) { scanf("%lf",&t); num[i]=(__int64)((t+0.005)*100.0); sum+=num[i]; } if(sum<k) res=0; else res=findx(0,sum/k+1); printf("%I64d.%02I64d\n",res/100,res%100); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator