1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 20 typedef long long ll; 21 typedef pair<int, int> pii; 22 23 const int INF = 0x7fffffff; 24 int win[2010][15][35]; 25 int T, y, m, d; 26 int key[] = {1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 27 28 bool check(int x) { 29 if (x % 4 != 0) { return false; } 30 if (x % 400 == 0) { return true; } 31 if (x % 100 == 0) { return false; } 32 return true; 33 } 34 35 int main() { 36 #ifdef __AiR_H 37 freopen("in.txt", "r", stdin); 38 // freopen("out.txt", "w", stdout); 39 #endif // __AiR_H 40 memset(win, true, sizeof(win)); win[2001][11][4] = false; 41 int t1, t2; bool flag; 42 for (int i = 2001; i >= 1900; --i) { 43 if (i == 2001) { t1 = 11; } else { t1 = 12; } 44 for (int j = t1; j >= 1; --j) { 45 flag = check(i); 46 if (flag) { key[2] = 29; } else { key[2] = 28; } 47 if (i == 2001 && j == 11) { t2 = 3; } else { t2 = key[j]; } 48 for (int k = t2; k >= 1; --k) { 49 win[i][j][k] = false; 50 y = i; m = j; d = k + 1; 51 if (d > key[m]) { d = 1; ++m; } 52 if (m > 12) { m = 1; ++y; } 53 if (!win[y][m][d]) { win[i][j][k] = true; } 54 y = i; m = j + 1; d = k; 55 if (m > 12) { m = 1; ++y; } 56 if (!win[y][m][d]) { win[i][j][k] = true; } 57 // if (win[i][j][k]) { printf("%d %d %d ", i, j, k); } 58 } 59 } 60 } 61 scanf("%d", &T); 62 while (T--) { 63 scanf("%d %d %d", &y, &m, &d); 64 if (win[y][m][d]) { printf("YES "); } else { printf("NO "); } 65 } 66 #ifdef __AiR_H 67 printf("Time used = %.2fs ", (double)clock() / CLOCKS_PER_SEC); 68 #endif // __AiR_H 69 return 0; 70 }
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 #define SZ(x) ((int)x.size()) 20 21 typedef long long ll; 22 typedef pair<int, int> pii; 23 const int maxn = 1e4 + 10; 24 int n, q, l, h, ans; 25 int s[maxn], SG[maxn]; 26 bool vis[maxn]; 27 28 void cal() { 29 SG[0] = 0; 30 for (int i = 1; i < maxn; ++i) { 31 memset(vis, false, sizeof(vis)); 32 for (int j = 1; j <= n; ++j) { 33 if (i - s[j] < 0) { continue; } 34 vis[SG[i - s[j]]] = true; 35 } 36 for (int j = 0; ; ++j) { 37 if (!vis[j]) { SG[i] = j; break; } 38 } 39 } 40 } 41 42 int main() { 43 #ifdef __AiR_H 44 freopen("in.txt", "r", stdin); 45 // freopen("out.txt", "w", stdout); 46 #endif // __AiR_H 47 while (scanf("%d", &n) && n) { 48 for (int i = 1; i <= n; ++i) { scanf("%d", &s[i]); } 49 cal(); scanf("%d", &q); 50 while (q--) { 51 scanf("%d", &l); ans = 0; 52 while (l--) { 53 scanf("%d", &h); ans ^= SG[h]; 54 } 55 if (ans) { printf("W"); } else { printf("L"); } 56 } 57 printf(" "); 58 } 59 return 0; 60 }
4 HDU 1847 Good Luck in CET-4 Everybody!
5 HDU 1848 Fibonacci again and again
6 HDU 1850 Being a Good Boy in Spring Festival
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 #define SZ(x) ((int)x.size()) 20 21 typedef long long ll; 22 typedef pair<int, int> pii; 23 const int maxn = 100 + 10; 24 int n; 25 int a[maxn]; 26 27 bool check(int i) { 28 int t = 0; 29 for (int j = 1; j <= n; ++j) { 30 if (j == i) { continue; } t ^= a[j]; 31 } 32 return t < a[i]; 33 } 34 35 int main() { 36 #ifdef __AiR_H 37 freopen("in.txt", "r", stdin); 38 // freopen("out.txt", "w", stdout); 39 #endif // __AiR_H 40 while (scanf("%d", &n) && n) { 41 int t = 0, ans = 0; 42 for (int i = 1; i <= n; ++i) { 43 scanf("%d", &a[i]); t ^= a[i]; 44 } 45 if (!t) { printf("0 "); continue; } 46 for (int i = 1; i <= n; ++i) { 47 if (check(i)) { ++ans; } 48 } 49 printf("%d ", ans); 50 } 51 return 0; 52 }
1 AtCoder Beginner Contest 059 D Alice&Brown
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 #define SZ(x) ((int)x.size()) 20 #define PI acos(-1.0) 21 #define lc id << 1 22 #define rc id << 1 | 1 23 #define lson low, mid, lc 24 #define rson mid + 1, high, rc 25 26 typedef long long ll; 27 typedef unsigned long long ull; 28 typedef pair<int, int> pii; 29 int T, n; 30 31 int main() { 32 #ifdef __AiR_H 33 freopen("in.txt", "r", stdin); 34 // freopen("out.txt", "w", stdout); 35 #endif // __AiR_H 36 scanf("%d", &T); 37 while (T--) { 38 scanf("%d", &n); 39 if (n % 7 == 0 || n % 7 == 2) { printf("B "); } 40 else { printf("A "); } 41 } 42 return 0; 43 }
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 #define SZ(x) ((int)x.size()) 20 #define PI acos(-1.0) 21 #define lc id << 1 22 #define rc id << 1 | 1 23 #define lson low, mid, lc 24 #define rson mid + 1, high, rc 25 26 typedef long long ll; 27 typedef unsigned long long ull; 28 typedef pair<int, int> pii; 29 const int maxn = 1e3 + 10; 30 int T, len; 31 char s[maxn]; 32 33 int main() { 34 #ifdef __AiR_H 35 freopen("in.txt", "r", stdin); 36 // freopen("out.txt", "w", stdout); 37 #endif // __AiR_H 38 scanf("%d", &T); 39 while (T--) { 40 scanf("%s", &s); len = strlen(s); int ans = 0; 41 for (int i = 0; i < len; ++i) { 42 ans += s[i] - '0'; ans %= 3; 43 } 44 if (ans) { printf("A "); } else { printf("B "); } 45 } 46 return 0; 47 }
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 #define SZ(x) ((int)x.size()) 20 #define PI acos(-1.0) 21 #define lc id << 1 22 #define rc id << 1 | 1 23 #define lson low, mid, lc 24 #define rson mid + 1, high, rc 25 26 typedef long long ll; 27 typedef unsigned long long ull; 28 typedef pair<int, int> pii; 29 const int maxn = 45; 30 int key[maxn]; 31 set<int> s; 32 int T, n; 33 34 int main() { 35 #ifdef __AiR_H 36 freopen("in.txt", "r", stdin); 37 // freopen("out.txt", "w", stdout); 38 #endif // __AiR_H 39 key[0] = 1; key[1] = 1; s.insert(1); 40 for (int i = 2; i < maxn; ++i) { 41 key[i] = key[i - 1] + key[i - 2]; 42 s.insert(key[i]); 43 } 44 scanf("%d", &T); 45 while (T--) { 46 scanf("%d", &n); 47 if (s.find(n) == s.end()) { printf("A "); } 48 else { printf("B "); } 49 } 50 return 0; 51 }
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <queue> 7 #include <vector> 8 #include <stack> 9 #include <map> 10 #include <set> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 using namespace std; 16 17 #define REP(i, n) for (int i = 0; i < (n); ++i) 18 #define eps 1e-9 19 #define SZ(x) ((int)x.size()) 20 #define PI acos(-1.0) 21 #define lc id << 1 22 #define rc id << 1 | 1 23 #define lson low, mid, lc 24 #define rson mid + 1, high, rc 25 26 typedef long long ll; 27 typedef unsigned long long ull; 28 typedef pair<int, int> pii; 29 const int maxn = 100 + 10; 30 const double k = (sqrt(5.0) + 1.0) / 2.0; 31 int T, x, y; 32 33 int main() { 34 #ifdef __AiR_H 35 freopen("in.txt", "r", stdin); 36 // freopen("out.txt", "w", stdout); 37 #endif // __AiR_H 38 scanf("%d", &T); 39 while (T--) { 40 scanf("%d %d", &x, &y); 41 if (x > y) { swap(x, y); } 42 if (x == (int)(k * (y - x))) { printf("B "); } 43 else { printf("A "); } 44 } 45 return 0; 46 }