标签:style blog http color os java io for ar
1 3 0.5 1 2 3
3
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define pii pair<int,int> 15 #define INF 0x3f3f3f3f 16 using namespace std; 17 18 int main() { 19 int t,n,sum,i,j,d[45],dp[45]; 20 double p; 21 LL need,all; 22 scanf("%d",&t); 23 while(t--){ 24 scanf("%d %lf",&n,&p); 25 for(i = sum = 0; i < n; i++){ 26 scanf("%d",d+i); 27 sum += d[i]; 28 } 29 memset(dp,0,sizeof(dp)); 30 dp[0] = 1; 31 all = 1LL<<n; 32 for(i = 0; i < n; i++){ 33 for(j = sum; j >= d[i]; j--) 34 if(dp[j-d[i]]) dp[j] += dp[j-d[i]]; 35 } 36 need = ceil(all*p); 37 for(i = all = 0; i <= sum; i++){ 38 all += dp[i]; 39 if(all >= need){ 40 printf("%I64d\n",i); 41 break; 42 } 43 } 44 } 45 return 0; 46 }
HDU 4815 Little Tiger vs. Deep Monkey
标签:style blog http color os java io for ar
原文地址:http://www.cnblogs.com/crackpotisback/p/3938743.html