A.cc:
1#include <iostream>
2using namespace std;
3
4int main()
5{
6 int t;
7 cin >> t;
8 while (t--) {
9 int n;
10 cin >> n;
11 if (n == 1) {
12 cout << 2 << endl;
13 } else if (n == 2) {
14 cout << 1 << endl;
15 } else if (n == 3) {
16 cout << 1 << endl;
17 } else {
18 cout << (n - 1) / 3 + 1 << endl;
19 }
20 }
21
22 return 0;
23}
B.cc:
1#include <iostream>
2#include <string>
3using namespace std;
4
5int main()
6{
7 int t;
8 cin >> t;
9 while (t--) {
10 int m, n;
11 cin >> m >> n;
12 string cons(n, 'B');
13 while (m--) {
14 int k;
15 cin >> k;
16 k--;
17 if (k >= n / 2) {
18 k = n - 1 - k;
19 }
20 if (cons[k] == 'B') {
21 cons[k] = 'A';
22 } else if (cons[n - 1 - k] == 'B') {
23 cons[n - 1 - k] = 'A';
24 }
25 }
26 cout << cons << endl;
27 }
28 return 0;
29}
C.cc:
1#include <iostream>
2#include <iomanip>
3#include <vector>
4using namespace std;
5
6int main()
7{
8 int n, m;
9 cin >> n >> m;
10 int cnt = 0;
11 for (int i = 0; i < n; ++i) {
12 vector<int> v;
13 v.reserve(m);
14 for (int ii = 0; ii < m; ++ii) {
15 int a;
16 cin >> a;
17 v.push_back(a);
18 }
19
20 bool flag = true;
21 for (int ii = 0; ii < m; ++ii) {
22 int a;
23 cin >> a;
24 if (a != v[ii]) {
25 flag = false;
26 }
27 }
28 if (flag) ++cnt;
29 }
30
31 cout << setprecision(2) << fixed << 100 * double(cnt) / n << '%' << endl;
32
33 return 0;
34}
D.cc:
1#include <iostream>
2using namespace std;
3
4int main()
5{
6 int t;
7 cin >> t;
8 while (t--) {
9 int n;
10 cin >> n;
11 n -= 4;
12 int ans;
13 switch (n % 3) {
14 case 0: case 1:
15 ans = n / 3 - 1;
16 break;
17 default: // 2
18 ans = n / 3;
19 break;
20 }
21 cout << ans << endl;
22 }
23 return 0;
24}
E.cc:
1#include <iostream>
2#include <vector>
3#include <algorithm>
4using namespace std;
5
6int main()
7{
8 int t;
9 cin >> t;
10 while (t--) {
11 vector<int> a;
12 int n, k;
13 cin >> n >> k;
14 a.reserve(n);
15 while (n--) {
16 int i;
17 cin >> i;
18 a.push_back(i);
19 }
20
21 cout << (find(a.begin(), a.end(), 1) != a.end() ? "YES" : "NO") << endl;
22 }
23
24 return 0;
25}
F.cc:
1#include <iostream>
2#include <iomanip>
3using namespace std;
4
5constexpr int AB[] {10, 11, 20, 21, 30, 40, 50, 60, 70, 80, 90};
6constexpr int DAYS[] {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
7
8struct Date {
9 Date() = default;
10 Date(const Date&) = default;
11 Date& operator=(const Date&) = default;
12 Date(int y, int m, int d) : y{y}, m{m}, d{d} {}
13 Date(int a, int b) {
14 y = a * 1010 + b * 101;
15 m = b * 10 + a;
16 d = b * 10 + a;
17 }
18
19 bool isLeapYear() const {
20 return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
21 }
22
23 Date nextDay() const {
24 if (m == 2 && d == 28) {
25 if (isLeapYear()) {
26 return {y, m, d + 1};
27 }
28 }
29 if (m == 2 && d == 29) {
30 return {y, m + 1, 1};
31 }
32 if (m == 12 && d == DAYS[12]) {
33 return {y + 1, 1, 1};
34 }
35
36 if (d == DAYS[m]) {
37 return {y, m + 1, 1};
38 }
39
40 return {y, m, d + 1};
41 }
42
43 bool isPalindrome() const {
44 // if (d % 10 == 0) return false;
45 return y % 10 == m / 10
46 && y / 10 % 10 == m % 10
47 && y / 100 % 10 == d / 10
48 && y / 1000 == d % 10;
49 }
50
51 friend istream& operator>>(istream& is, Date& d) {
52 char raw_date[9];
53 is >> raw_date;
54 d.y = (raw_date[0] - '0') * 1000 + (raw_date[1] - '0') * 100 + (raw_date[2] - '0') * 10 + (raw_date[3] - '0') * 1;
55 d.m = (raw_date[4] - '0') * 10 + (raw_date[5] - '0') * 1;
56 d.d = (raw_date[6] - '0') * 10 + (raw_date[7] - '0') * 1;
57 return is;
58 }
59
60 friend ostream& operator<<(ostream& os, const Date& d) {
61 return (os << setfill('0')
62 << setw(4) << d.y
63 << setw(2) << d.m
64 << setw(2) << d.d);
65 }
66
67 bool operator<(const Date& rhs) {
68 if (this->y != rhs.y) {
69 return this->y < rhs.y;
70 } else if (this->m != rhs.m) {
71 return this->m < rhs.m;
72 } else {
73 return this->d < rhs.d;
74 }
75 }
76
77 bool operator==(const Date& rhs) {
78 return this->y == rhs.y && this->m == rhs.m && this->d == rhs.d;
79 }
80
81private:
82 int y, m, d;
83};
84
85
86int main()
87{
88 Date date;
89 cin >> date;
90
91 Date date1 = date.nextDay();
92 while (!date1.isPalindrome()) {
93 date1 = date1.nextDay();
94 }
95 cout << date1 << endl;
96
97 Date date2(AB[0] / 10, AB[1] % 10);
98 for (::size_t i = 1; i < sizeof(AB) / sizeof(int); ++i) {
99 if (!(date2 < date || date2 == date)) {
100 break;
101 }
102 date2 = Date(AB[i] / 10, AB[i] % 10);
103 }
104 cout << date2 << endl;
105
106 return 0;
107}