标签:
2 5 2 3.2 4 4.5 6 10 1 2 3 1 2 1.2 3 1.1 1 2
2 5
典型的贪心问题:
1 #include<iostream> 2 #include<algorithm> 3 #include<cmath> 4 using namespace std; 5 int main() 6 { 7 int n,m,i,count_n;double ri[1000],length; 8 cin>>m; 9 while(m--) 10 { 11 count_n=0; 12 length=0; 13 cin>>n; 14 for(i=0;i<n;i++) 15 cin>>ri[i]; 16 sort(ri,ri+n); 17 for(i=n-1;length<20;i--){ 18 length+=2*sqrt(ri[i]*ri[i]-1); 19 count_n++; 20 } 21 cout<<count_n<<endl; 22 } 23 }
标签:
原文地址:http://www.cnblogs.com/ljwTiey/p/4296541.html