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 |
Runtime Error,请各位大神帮我看一下哪里错了。。/* Poj 1064, wrote by Dream Chen 2010/12/12*/ #include <iostream> #include <string> using namespace std; int N = 0; int K = 0; int l = 0; int r = 0; int mid = 0; int a[11000]; int res = 0; bool judge(int t); int main(void) { memset((void*)a,0,sizeof(a)); while(EOF != scanf("%d %d",&N,&K)) { for (int i = 0; i < N; ++i) { double tmp = 0; scanf("%lf",&tmp); a[i] = (int)(tmp*100); if (a[i] > r) { r = a[i]; } } while(l <= r) { mid = (l + r) / 2; // suit the requiment if (judge(mid)) { l = mid + 1; } else { r = mid - 1; } } printf("%.2lf\n",r*0.01); } return 0; } bool judge(int t) { int sum = 0; for (int i = 0; i < N; ++i) { sum += a[i] / t; } if (sum >= K) { return true; } else { return false; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator