| ||||||||||
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 |
求牛人解惑!提交时提示WA,不知道哪错了 #include<iostream> #include<stdio.h> using namespace std; int fi[10000]; int j=0; void cha(int m,int n,int find[]) { int left=0,right=1000000-1; int mid; int a,i,stop; memset(fi,0,sizeof(fi)); while(left<=right) { mid=(left+right)/2; a=0; for(i=0;i<m;i++) a=a+find[i]/mid; if(n==a) { for(i=0;i<m;i++) { if(find[i]<mid) stop=0; } if(stop!=0) { fi[j]=mid; j++; stop=1; } } if(n>a) right=mid-1; else left=mid+1; } fi[j]=0.00; } int main() { int x,y,i,m[10000]; double length[10000]; int f; float final; memset(length,0,sizeof(length)); cin>>x>>y; for(i=0;i<x;i++) { cin>>length[i]; m[i]=int(length[i]*100); } cha(x,y,m); for(i=0;i<j;i++) { if(fi[i]<fi[i+1]) f=fi[i+1]; else {fi[i+1]=fi[i];f=fi[i];} } final=f/100.0; if(j==0) cout<<"0.00"<<endl; else printf("%.2f",final); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator