标签:int long color mit rip font precision equal 20px
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 41348 | Accepted: 8873 |
Description
Input
Output
Sample Input
4 11
8.02
7.43
4.57
5.39
Sample Output
2.00
Source
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<cmath> 5 using namespace std; 6 int n,k; 7 double a[10010]; 8 bool C(double x){ 9 int num=0; 10 for(int i=1;i<=n;i++) 11 num+=(int)(a[i]/x); 12 return num>=k; 13 } 14 void solve(){ 15 double l=0,r=10000000; 16 for(int i=0;i<=100;i++){ 17 double mid=(l+r)/2; 18 if(C(mid)) l=mid; 19 else r=mid; 20 } 21 printf("%.2lf",floor(r*100)/100); 22 } 23 int main() 24 { 25 scanf("%d%d",&n,&k); 26 for(int i=1;i<=n;i++) 27 scanf("%lf",&a[i]); 28 solve(); 29 return 0; 30 }
思路:二分搜索~~
标签:int long color mit rip font precision equal 20px
原文地址:http://www.cnblogs.com/suishiguang/p/6358736.html