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 <iostream> #include <string> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <map> #define range(i,a,b) for(int i=a;i<=b;++i) #define LL long long #define rerange(i,a,b) for(int i=a;i>=b;--i) #define fill(arr,tmp) memset(arr,tmp,sizeof(arr)) using namespace std; int t,n; double aa[1005]; void init(){ cin>>t; } void solve(){ while(t--){ cin>>n; range(i,0,n-1)cin>>aa[i]; sort(aa,aa+n); int cnt=0;double now=0; rerange(i,n-1,0){ if(now>=20)break; now+=2*sqrt(aa[i]*aa[i]-1); ++cnt; } cout<<cnt<<endl; } } int main() { init(); solve(); return 0; }
原文:https://www.cnblogs.com/Rhythm-/p/9344632.html