题目链接:here
Convex
可能是最水的一道题了,用了很麻烦的做法.....
Find Small A
HDU - 5980签到题
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define LL long long 4 int main(){ 5 int n; 6 //freopen("in.txt", "r", stdin); 7 while(scanf("%d", &n) != EOF){ 8 int cnt = 0; 9 LL x; 10 for(int i = 0; i < n; i++){ 11 scanf("%lld", &x); 12 int pos = 0; 13 while(x){ 14 int temp = x & 255; 15 x >>= 8; 16 if(temp == 97) cnt++; 17 } 18 } 19 printf("%d ", cnt); 20 } 21 }
To begin or not to begin
发现真的很简单啊......
学过概率的就知道这种事情如果每个人只取一次,先后手对结果没有影响,那么只要看谁能取的次数多就好了
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int main(){ 5 int n; 6 while(scanf("%d", &n) != EOF){ 7 if(n&1){ 8 puts("0"); 9 }else { 10 puts("1"); 11 } 12 } 13 }
Wrestling Match
二分图染色,感觉题意不是很清楚,一开始没敢写...
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int maxv = 1010; 5 const int maxe = 10010; 6 7 struct Edge{ 8 int v, nex; 9 Edge(int v = 0, int nex = 0) : v(v), nex(nex) {} 10 }e[maxe<<1]; 11 int head[maxv]; 12 int cnt; 13 14 void init(){ 15 memset(head, -1, sizeof(head)); 16 cnt = 0; 17 } 18 void add(int u, int v){ 19 e[cnt] = Edge(v, head[u]); 20 head[u] = cnt++; 21 e[cnt] = Edge(u, head[v]); 22 head[v] = cnt++; 23 } 24 int color[maxv]; 25 26 bool Bigraph(int u){ 27 for(int i = head[u]; ~i; i = e[i].nex){ 28 int v = e[i].v; 29 if(color[v] == color[u]) return 0; 30 if(!color[v]){ 31 color[v] = 3 - color[u]; 32 if(!Bigraph(v)) return 0; 33 } 34 } 35 return 1; 36 } 37 38 int main(){ 39 int n, m , x, y; 40 //freopen("in.txt", "r", stdin); 41 while(scanf("%d %d %d %d", &n, &m, &x, &y) != EOF) { 42 int u, v; 43 init(); 44 memset(color, 0, sizeof(color)); 45 for(int i = 0; i < m; i++){ 46 scanf("%d %d", &u, &v); 47 add(u, v); 48 } 49 for(int i = 0; i < x; i++){ 50 scanf("%d", &u); 51 color[u] = 1; 52 } 53 for(int i = 0; i < y; i++){ 54 scanf("%d", &v); 55 color[v] = 2; 56 } 57 int ok = 1; 58 for(int u = 1; u <= n; u++){ 59 if(color[u]) { 60 if(!Bigraph(u)) { 61 ok = 0; 62 break; 63 } 64 } 65 } 66 for(int i = 1; ok && i <= n; i++){ 67 if(!color[i]){ 68 if(head[i] == -1) { 69 ok = 0; 70 break; 71 } else { 72 color[i] = 1; 73 if(!Bigraph(i)) { 74 ok = 0; 75 break; 76 } 77 } 78 } 79 } 80 if(ok) puts("YES"); 81 else puts("NO"); 82 } 83 }
Detachment
队友过的~
首先要清楚的是分成的肯定是2到x的一个公差为1的等差数列,然后多出来的加到后面就可以了
A Simple Math Problem
也是队友过的,不过队友好像是枚举了a的因子做的.
发现正解很巧妙的用到了数论的知识
Regular Number
这个题...对于我们来说好像不可做,一是自己没用过bitset,二是从来没见过这种匹配算法Shift-And
感觉很不错,学习下~
bitset基本操作(转自here)
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 5e6+10; 4 bitset<1010> B[11], ans; 5 char s[maxn]; 6 int main(){ 7 int n; 8 //freopen("in.txt", "r", stdin); 9 // for(int i = 0 ; i < 11; i++) B[i].reset(); 10 // ans.reset(); 11 scanf("%d", &n); 12 for(int i = 0; i < n; i++){ 13 int m, x; 14 scanf("%d", &m); 15 for(int j = 0; j < m; j++) { 16 scanf("%d", &x); 17 B[x].set(i); 18 } 19 } 20 scanf("%s", s); 21 int len = strlen(s); 22 for(int i = 0; i < len; i++){ 23 ans <<= 1; 24 ans[0] = 1; 25 ans &= B[s[i] - '0']; 26 if(ans[n-1] == 1) { 27 char c = s[i+1]; 28 s[i+1] = 0; 29 puts(&s[i-n+1]); 30 s[i+1] = c; 31 } 32 } 33 return 0; 34 }