1.3880
2.39001250856960000
3.35357670
4.173
5.479306
6.3141
7. 稍小分数
8.Excel地址
#includeusing namespace std; void main() { int num; cin >> num; char p[10]; for (int i = 0; i < 10; i++) { p[i] = NULL; } int i = 0; while (num > 0) { p[i++] = (num - 1) % 26 + 'A'; num -= (num - 1) % 26 + 1; num /= 26; } p[i] = ' '; for (i = 9; i >= 0; i--) { if (p[i] != ' ') cout << p[i]; } }
9.日期问题
#includeusing namespace std; int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; void nyr(int a, int b, int c) { if (a >= 60) a = 1900 + a; else a = 2000 + a; if ((a % 4 == 0) && (a % 100 != 0) || (a % 400 == 0)) month[2] = 29; if (b <= 12 && c <= month[b]) printf("%04d-%02d-%02dn", a, b, c); } void yrn(int a, int b, int c) { if (c >= 60) c = 1900 + c; else c = 2000 + c; if ((c % 4 == 0) && (c % 100 != 0) || (c % 400 == 0)) month[2] = 29; if (a <= 12 && b <= month[a]) printf("%04d-%02d-%02dn", c, a, b); } void ryn(int a, int b, int c) { if (a >= 60) c = 1900 + c; else c = 2000 + c; if ((c % 4 == 0) && (c % 100 != 0) || (c % 400 == 0)) month[2] = 29; if (b <= 12 && a <= month[b]) printf("%04d-%02d-%02dn", c, b, a); } int main() { int a, b, c; char z; cin >> a >> z>>b >> z >> c; nyr(a, b, c); yrn(a, b, c); ryn(a, b, c); return 0; }
10.整数划分
#includeusing namespace std; int a(int n, int m) { if (n == 1 || m == 1) return 1; else if (n < m) return a(n, n); else if (n == m) return 1 + a(n, n - 1); else return a(n, m - 1) + a(n - m, m); } int main() { int num, result; cin >> num; result= a(num, num); cout << result; return 0; }
11.97
12.
#includeusing namespace std; #include #define ll long long int ans; int map[50][50]; void DFS(int line, int re_A, int re_B, int n) { int A = re_A; int B = re_B; if (re_A < 0 || re_B < 0) return; if (line == n && A == 0 && B == 0) { ans++; return; } re_A = A; re_B = B; map[line][0] = 0; re_A -= 1; for (int i = 1;i <= line;i++) { map[line][i] = map[line][i - 1] ^ map[line - 1][i - 1]; if (map[line][i] == 0) { re_A--; } else { re_B--; } } DFS(line + 1, re_A, re_B, n); re_A = A; re_B = B; map[line][0] = 1; re_B -= 1; for (int i = 1;i <= line;i++) { map[line][i] = map[line][i - 1] ^ map[line - 1][i - 1]; if (map[line][i] == 0) re_A--; else re_B--; } DFS(line + 1, re_A, re_B, n); } int main() { int x, y, n; while (cin >> x >> y) { ans = 0; for (int i = 1;;i++) { if (2 * x + 2 * y == i * i + i) { n = i; break; } } DFS(0, x, y, n); cout << ans << endl; } }
13.10 3 9 8



