[BNU弱校联萌]如日中天

比赛链接:http://acm.bnu.edu.cn/v3/contest_show.php?cid=6867#info

第一次进前100,好激动好激动。

A.状压,把每个属性按位存在一个数里,比对的时候按位搞一发完事。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 #include <iomanip>
 6 #include <cmath>
 7 #include <map>
 8 #include <vector>
 9 #include <string>
10 #include <queue>
11 #include <set>
12 #include <algorithm>
13 
14 using namespace std;
15 
16 const int maxn = 100010;
17 int score[maxn], trait[maxn];
18 int n, k;
19 
20 int main() {
21     // freopen("in", "r", stdin);
22     while(~scanf("%d %d", &n, &k)) {    
23         int y, f;
24         memset(trait, 0, sizeof(trait));
25         for(int i = 0; i < n; i++) {
26             scanf("%d %d", &score[i], &y);
27             for(int j = 0; j < y; j++) {
28                 scanf("%d", &f);
29                 trait[i] += (1 << f);
30             }
31         }
32         int m;
33         scanf("%d", &m);
34         while(m--) {
35             int t, a, h;
36             int cur = 0, ans = 1;
37             scanf("%d %d", &a, &t);
38             a--;
39             for(int i = 0; i < t; i++) {
40                 scanf("%d", &h);
41                 cur += (1 << h);
42             }
43             for(int i = 0; i < n; i++) {
44                 if((trait[i] & cur) == (trait[a] & cur) && score[i] > score[a]) {
45                     ans++;
46                 }
47             }
48             printf("%d\n", ans);
49         }
50     }
51 }
A

 

C.看懂题就行了,找比平均值大的数,注意会爆int。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 #include <iomanip>
 6 #include <cmath>
 7 #include <map>
 8 #include <vector>
 9 #include <string>
10 #include <queue>
11 #include <set>
12 #include <algorithm>
13 
14 using namespace std;
15 
16 const int maxn = 1010;
17 int n;
18 double l[maxn];
19 long long s;
20 
21 int main() {
22     while(~scanf("%d", &n)) {
23         s = 0;
24         double ave = 0;
25         for(int i = 0; i < n; i++) {
26             scanf("%lld", &l[i]);
27             ave += l[i];
28         }
29         ave = (ave) / n;
30         for(int i = 0; i < n; i++) {
31             if(l[i] > ave) {
32                 s++;
33             }
34         }
35         printf("%I64d\n", s);
36     }
37     return 0;
38 }
C

 

I.数学题?规律题?题目给了提示从一个角开始铺,固定一边往下铺,再看看是不是还能铺一层。接着剩下两条小的,再算一下需要多少小小块即可。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 #include <iomanip>
 6 #include <cmath>
 7 #include <map>
 8 #include <vector>
 9 #include <string>
10 #include <queue>
11 #include <set>
12 #include <algorithm>
13 
14 using namespace std;
15 
16 int bigl, smll;
17 int bigh, smlh;
18 
19 int main() {
20     // freopen("in", "r", stdin);
21     while(~scanf("%d %d %d %d", &bigl, &bigh, &smll, &smlh)) {
22         float numl = floor(bigl / smll);
23         float numh = floor(bigh / smlh);
24         float cutl = bigl - (smll * numl);
25         float cutln = floor(smll / cutl);
26         float extl = ceil(numh / cutln);
27 
28         int need = 0;
29         if (int(numh) % int(cutln) == 0) {
30             need = 1;
31         }
32 
33         float cuth = bigh - (smlh * numh);
34         float cuthn = floor(smlh / cuth);
35 
36         float call = bigl;
37         if (need == 0) {
38             call = numl * smll;
39         }
40         float exth = ceil(ceil(call / smll) / cuthn);
41         // printf("%lf %lf\n", need, cutln);
42         printf("%d\n", int(numl * numh + extl + exth));
43     }
44 }
I

 

posted @ 2015-10-04 21:07  Kirai  阅读(185)  评论(0编辑  收藏  举报