标签:
枚举
练的时候以为是dp---(事实上这场只做了10来分钟---就愉快地滚去吃饭了---)
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 int A,B,C,D,E; 7 int a[15];//汤 8 int b[15];//饭 9 int c[15];//面 10 int d[15];//荤 11 int e[15];//素 12 int minn,maxx; 13 int sum; 14 15 //一荤一素 16 //一荤两素 17 //两荤一素 18 //两荤两素 19 20 void solve(){ 21 int res = 0; 22 23 for(int i = 1;i <= B;i++){ 24 for(int j = 1;j <= A;j++){ 25 sum = 0; 26 27 for(int p = 1;p <= D;p++){ 28 for(int q = 1;q <= E;q++){ 29 sum = b[i] + a[j]; 30 sum += d[p] + e[q]; 31 if(sum >= minn && sum <= maxx) res++; 32 } 33 } 34 35 for(int p=1;p <= D;p++){ 36 for(int q=1;q <= E;q++){ 37 for(int z = q+1;z <= E;z++){ 38 sum = b[i] + a[j]; 39 sum += d[p] + e[q] + e[z]; 40 if(sum >= minn && sum <= maxx) res++; 41 } 42 } 43 } 44 45 46 for(int p=1;p <= D;p++){ 47 for(int q = p+1;q <= D;q++){ 48 for(int z = 1;z <= E;z++){ 49 sum = b[i]+a[j]; 50 sum += d[p] + d[q] + e[z]; 51 if(sum >= minn && sum <= maxx) res++; 52 } 53 } 54 } 55 56 for(int p=1;p <= D;p++){ 57 for(int q = p+1;q <= D;q++){ 58 for(int z = 1;z <= E;z++){ 59 for(int zz = z+1;zz <= E;zz++){ 60 sum = b[i]+a[j]; 61 sum += d[p] + d[q] + e[z] + e[zz]; 62 if(sum >= minn && sum <= maxx) res++; 63 } 64 65 } 66 } 67 } 68 69 70 } 71 } 72 73 for(int i = 1;i <= C;i++){ 74 sum = c[i]; 75 for(int p = 1;p <= D;p++){ 76 for(int q = 1;q <= E;q++){ 77 sum = c[i]; 78 sum += d[p] + e[q]; 79 if(sum >= minn && sum <= maxx) res++; 80 } 81 } 82 83 for(int p=1;p <= D;p++){ 84 for(int q=1;q <= E;q++){ 85 for(int z = q+1;z <= E;z++){ 86 sum = c[i]; 87 sum += d[p] + e[q] + e[z]; 88 if(sum >= minn && sum <= maxx) res++; 89 } 90 } 91 } 92 93 for(int p=1;p <= D;p++){ 94 for(int q = p+1;q <= D;q++){ 95 for(int z = 1;z <= E;z++){ 96 sum = c[i]; 97 sum += d[p] + d[q] + e[z]; 98 if(sum >= minn && sum <= maxx) res++; 99 } 100 } 101 } 102 103 for(int p=1;p <= D;p++){ 104 for(int q = p+1;q <= D;q++){ 105 for(int z = 1;z <= E;z++){ 106 for(int zz = z+1;zz <= E;zz++){ 107 sum = c[i]; 108 sum += d[p] + d[q] + e[z] + e[zz]; 109 if(sum >= minn && sum <= maxx) res++; 110 } 111 112 } 113 } 114 } 115 } 116 printf("%d\n",res); 117 } 118 119 int main(){ 120 int T; 121 scanf("%d",&T); 122 while(T--){ 123 scanf("%d %d %d %d %d",&A,&B,&C,&D,&E); 124 for(int i = 1;i <= A;i++) scanf("%d",&a[i]); 125 for(int i = 1;i <= B;i++) scanf("%d",&b[i]); 126 for(int i = 1;i <= C;i++) scanf("%d",&c[i]); 127 for(int i = 1;i <= D;i++) scanf("%d",&d[i]); 128 for(int i = 1;i <= E;i++) scanf("%d",&e[i]); 129 scanf("%d %d",&minn,&maxx); 130 131 solve(); 132 133 } 134 return 0; 135 }
string sort一下
wtw敲的---
还是wtw敲的----
没有编译就交了----
果然这场比赛打得不认真---
标签:
原文地址:http://www.cnblogs.com/wuyuewoniu/p/4899679.html