和杭电那一题一样,只不过G++交不能通过,C++能过
wa了好多好多好多次-----------------------------------------
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<stack> 6 #include<vector> 7 #include<map> 8 #include<set> 9 #include<queue> 10 #include<algorithm> 11 using namespace std; 12 13 typedef long long LL; 14 const int INF = (1<<30)-1; 15 const int mod=1000000007; 16 const int maxn=10005; 17 const int Exp=1e-6; 18 19 double a[maxn]; 20 int n,k; 21 22 bool ok(double x){ 23 int ans=0; 24 for(int i=0;i<n;i++){ 25 ans+=(int) (a[i]/x ); 26 } 27 return ans>=k; 28 } 29 30 int main(){ 31 scanf("%d %d",&n,&k); 32 for(int i=0;i<n;i++) scanf("%lf",&a[i]); 33 34 double lb=0,ub= INF,mid; 35 for(int i=0;i < 100;i++){ 36 mid=(lb + ub)/2; 37 if(ok(mid)) lb=mid; 38 else ub=mid; 39 40 // printf("lb=%lf ",lb); 41 // printf("ub=%lf ",ub); 42 // printf("mid=%lf ",mid); 43 } 44 printf("%.2lf ",(floor)(mid*100)/100); 45 46 return 0; 47 }