标签:else nbsp get color str blank ret ble problem
题目连接:http://poj.org/problem?id=2976
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int maxn=1010; 6 double a[maxn],b[maxn],d[maxn]; 7 int n,k; 8 bool check(double x) 9 { 10 double ans=0; 11 for(int i=0;i<n;i++) 12 d[i]=a[i]-x*b[i]; 13 sort(d,d+n); 14 for(int i=k;i<n;i++) 15 ans+=d[i]; 16 return ans>0; 17 } 18 19 int main() 20 { 21 while(scanf("%d%d",&n,&k)&&(n||k)) 22 { 23 for(int i=0;i<n;i++) 24 scanf("%lf",&a[i]); 25 for(int i=0;i<n;i++) 26 scanf("%lf",&b[i]); 27 double l=0,r=1.0,mid; 28 while(r-l>1e-7) 29 { 30 mid=(l+r)*1.0/2; 31 if(check(mid)) l=mid; 32 else r=mid; 33 } 34 printf("%.0f\n",mid*100); 35 } 36 }
标签:else nbsp get color str blank ret ble problem
原文地址:http://www.cnblogs.com/yijiull/p/6740194.html