标签:
2 5 2 3.2 4 4.5 6 10 1 2 3 1 2 1.2 3 1.1 1 2
2 5
#include<cstdio> #include<algorithm> #include<cmath> using namespace std; bool cmp(double a,double b) { return a>b; } int main() { int t,i,j; int len,n; double a[1010]; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i=0;i<n;++i) { scanf("%lf",a+i); } sort(a,a+n,cmp); double s=20; int k=0; while(s>0) { s=s-sqrt(a[k]*a[k]-1)*2; k++; } printf("%d\n",k); } return 0; }
#include<iostream> #include<algorithm> #include<cmath> using namespace std; bool cmp1(const double& a,const double& b) { return a>b; } int main() { int i,n,m,k; double a[610],s; cin >> n; while(n--) { cin >> m; for(i=0;i<m;++i) { cin >> a[i]; /* if(a[i]<=1)//若是无效的装置 { i--; m--; }*/ } sort(a,a+m,cmp1); s=20; k=0; while(s>0) { s=s-sqrt(a[k]*a[k]-1)*2; k++; } cout << k << endl; } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/yuzhiwei1995/article/details/47167137