12#include <unordered_map>
13#include <unordered_set>
31 " #..###.....##....\n"
32 " ###.......###### ### ###\n"
33 " ........... #...# #...#\n"
34 " ##*####### #.#.# #.#.#\n"
35 " ####*******###### #.#.# #.#.#\n"
36 " ...#***.****.*###.... #...# #...#\n"
37 " ....**********##..... ### ###\n"
38 " ....**** *****....\n"
41 "##############################################################\n"
42 "#...#......#.##...#......#.##...#......#.##------------------#\n"
43 "###########################################------------------#\n"
44 "#..#....#....##..#....#....##..#....#....#####################\n"
45 "########################################## #----------#\n"
46 "#.....#......##.....#......##.....#......# #----------#\n"
47 "########################################## #----------#\n"
48 "#.#..#....#..##.#..#....#..##.#..#....#..# #----------#\n"
49 "########################################## ############";
54 for(
unsigned short i = 1; i <= 3; i++) {
55 for(
unsigned short j = 1; j <= 9; j++) {
59 for(
unsigned short k = 1; k <= 9; k++) {
60 if(k == i || k == j || k * 2 % 10 == j || k * 2 % 10 == i || k * 3 % 10 == j || k * 3 % 10 == i || k == 5) {
63 const unsigned short num = 100 * i + 10 * j + k;
67 unsigned short num2 = 2 * num;
68 unsigned short num3 = 3 * num;
69 auto um = unordered_set<unsigned short>();
73 unsigned short n = num2 % 10;
75 if(um.contains(n) || n == 0) {
81 if(um.contains(n) || n == 0) {
87 if(um.contains(n) || n == 0) {
93 if(um.contains(n) || n == 0) {
99 if(um.contains(n) || n == 0) {
105 if(um.contains(n) || n == 0) {
109 cout << num <<
" " << num * 2 <<
" " << num * 3 << endl;
121 cin >> n >> m >> cx >> cy;
122 unsigned long long board[21][21] = {};
124 for(
int i = 0; i <= n; i++) {
125 for(
int j = 0; j <= m; j++) {
126 if(abs(cx - i) * abs(cy - j) == 2 || i == cx && j == cy) {
131 board[i][j] += board[i - 1][j];
134 board[i][j] += board[i][j - 1];
143 auto as = vector<unsigned int>();
144 auto bs = vector<unsigned int>();
145 auto gs = vector<unsigned int>();
146 auto ks = vector<unsigned int>();
149 for(
int i = 0; i < n; i++) {
154 cin >> a >> b >> g >> k;
163 for(
int i = n - 1; i >= 0; i--) {
164 if(as[i] <= x && x <= as[i] + gs[i] && bs[i] <= y && y <= bs[i] + ks[i]) {
184 cout << static_cast<char>(toupper(ch));
191 for(
int i = s.length() - 1; i >= 0; i--) {
201 cout << setiosflags(ios::fixed) << setprecision(3) << t / n << endl
211 cin >> a >> b >> c >> d;
212 const int diff = (c - a) * 60 + d - b;
213 cout << diff / 60 <<
" " << diff % 60;
221 cout <<
"I love Luogu!";
223 cout << 2 + 4 <<
" " << 10 - 2 - 4;
225 cout << 14 / 4 << endl
226 << 14 / 4 * 4 << endl
229 cout << setiosflags(ios::fixed) << setprecision(3) << 500.0 / 3.0;
231 cout << (260 + 220) / (12 + 20);
233 cout << sqrt(6 * 6 + 9 * 9);
237 cout << deposit << endl;
239 cout << deposit << endl;
241 cout << deposit << endl;
243 cout << 2 * 5 * 3.141593 << endl;
244 cout << 5 * 5 * 3.141593 << endl;
245 cout << 4 * 5 * 5 * 5 * 3.141593 / 3 << endl;
248 cout << (((peach + 1) * 2 + 1) * 2 + 1) * 2;
254 cout <<
'M' -
'A' + 1 << endl;
255 cout << static_cast<char>(
'A' - 1 + 18);
258 const double r2 = 10;
259 const double v1 = 4 * r1 * r1 * r1 * 3.141593 / 3;
260 const double v2 = 4 * r2 * r2 * r2 * 3.141593 / 3;
261 cout << static_cast<int>(pow(v1 + v2, 1.0 / 3.0));
273 const double p = (a + b + c) / 2;
274 cout << setiosflags(ios::fixed) << setprecision(1) << sqrt(p * (p - a) * (p - b) * (p - c));
282 cout << (10 * a + b) / 19;
299 cout << max(0, m - eaten);
304 unsigned long long n;
305 unsigned long long count = 0;
307 for(
long long i = 1; i <= n - 2; i++) {
308 count += i * (n - 2 - i);
320 double t = 8 * 60 - (
static_cast<double>(s) /
static_cast<double>(v) + 10);
324 const int h =
static_cast<int>(t / 60);
325 const int m =
static_cast<int>(t) % 60;
342 cout << (a * 2 + b * 3 + c * 5) / 10;
349 const bool b1 = x % 2 == 0;
350 const bool b2 = x > 4 && x <= 12;
351 cout << static_cast<int>(b1 && b2) <<
" " <<
static_cast<int>(b1 || b2) <<
" " << (b1 xor b2) <<
" " <<
static_cast<int>(!b1 && !b2);
360 if(year % 100 == 0) {
362 if(year % 400 == 0) {
383 cout <<
"Today, I ate " << x <<
" apple";
394 const unsigned int local = n * 5;
395 const unsigned int luogu = 11 + 3 * n;
406 cin >> abc[0] >> abc[1] >> abc[2];
408 for(
const auto i: abc) {
418 const double bmi = m / (n * n);
420 cout <<
"Underweight";
421 }
else if(bmi >= 18.5 && bmi < 24) {
433 cin >> year >> month;
434 const bool bissextile = year % 400 == 0 || year % 4 == 0 && year % 100 != 0;
435 if(month == 4 || month == 6 || month == 9 || month == 11) {
437 }
else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
439 }
else if(bissextile) {
450 unsigned int maximum = 0;
451 unsigned int maximum_i = 0;
453 while(cin >> a && cin >> b) {
455 if(a + b > 8 && a + b > maximum) {
470 for(
int i = 0; i < 3; i++) {
476 int sum = count * price;
477 minimum = minimum == -1 ? sum : min(minimum, sum);
486 const string isbn_prefix = isbn.substr(0, isbn.length() - 1);
489 for(
const char ch: isbn_prefix) {
490 if(isdigit(ch) != 0) {
491 sum += (ch -
'0') * count++;
496 int end = *isbn.rbegin() -
'0';
497 if(end ==
'X' -
'0') {
507 cout << isbn_prefix << static_cast<char>(end +
'0');
516 cout << setiosflags(ios::fixed) << setprecision(1);
518 fee = power * 0.4463;
519 }
else if(power <= 400) {
520 fee = 150 * 0.4463 + (power - 150) * 0.4663;
522 fee = 150 * 0.4463 + (400 - 150) * 0.4663 + (power - 400) * 0.5663;
524 cout << floor(fee * 10 + 0.5) / 10;
533 unsigned int count = n / 7 * 5 * 250;
535 for(
unsigned int i = 0; i < n; i++) {
536 if((x + i) % 7 < 5) {
551 maximum = max(maximum, b);
552 maximum = max(maximum, c);
553 minimum = min(minimum, b);
554 minimum = min(minimum, c);
555 const int g =
gcd(maximum, minimum);
556 cout << minimum / g <<
"/" << maximum / g;
579 for(
const int i: h) {
590 cin >> e[0] >> e[1] >> e[2];
592 if(e[0] + e[1] <= e[2]) {
593 cout <<
"Not triangle" << endl;
595 const unsigned int e02 = e[0] * e[0];
596 const unsigned int e12 = e[1] * e[1];
597 const unsigned int e22 = e[2] * e[2];
598 if(e02 + e12 == e[2] * e[2]) {
599 cout <<
"Right triangle" << endl;
600 }
else if(e02 + e12 > e22) {
601 cout <<
"Acute triangle" << endl;
602 }
else if(e02 + e12 < e22) {
603 cout <<
"Obtuse triangle" << endl;
606 cout <<
"Isosceles triangle" << endl;
608 cout <<
"Equilateral triangle" << endl;
617 cin >> num[0] >> num[1] >> num[2];
621 for(
const unsigned int i: num) {
629 for(
const unsigned int i: num) {
630 if(i != a && i != c) {
635 for(
int i = 0; i < 3; i++) {
639 }
else if(ch ==
'B') {
653 for(
int i = 0; i < n; i++) {
655 minimum = min(minimum, a);
669 for(
int i = 1; i <= n; i++) {
678 cout << fixed << setprecision(1) << static_cast<double>(sum_a) /
static_cast<double>(count_a) <<
" " <<
static_cast<double>(sum_b) /
static_cast<double>(count_b);
698 for(
int i = n; i >= 1; i--) {
699 for(
int j = 0; j < i; j++) {
700 cout << setw(2) << setfill(
'0') <<
right << count++;
710 const string ans[] = {
"",
"1",
"3",
"9",
"33",
"153",
"873",
"5913",
"46233",
"409113",
"4037913",
"43954713",
"522956313",
"6749977113",
"93928268313",
"1401602636313",
"22324392524313",
"378011820620313",
"6780385526348313",
"128425485935180313",
"2561327494111820313",
"53652269665821260313",
"1177652997443428940313",
"27029669736328405580313",
"647478071469567844940313",
"16158688114800553828940313",
"419450149241406189412940313",
"11308319599659758350180940313",
"316196664211373618851684940313",
"9157958657951075573395300940313",
"274410818470142134209703780940313",
"8497249472648064951935266660940313",
"271628086406341595119153278820940313",
"8954945705218228090637347680100940313",
"304187744744822368938255957323620940313",
"10637335711130967298604907294846820940313",
"382630662501032184766604355445682020940313",
"14146383753727377231082583937026584420940313",
"537169001220328488991089808037100875620940313",
"20935051082417771847631371547939998232420940313",
"836850334330315506193242641144055892504420940313",
"34289376947494122614363304694584807557656420940313",
"1439295494700374021157505910939096377494040420940313",
"61854558558074209658512637979453093884758552420940313",
"2720126133346522977702138448994068984204397080420940313",
"122342346998826717539665299944651784048588130840420940313",
"5624964506810915667389970728744906677010239883800420940313",
"264248206017979096310354325882356886646207872272920420940313",
"12678163798554051767172643373255731925167694226950680420940313",
"620960027832821612639424806694551108812720525606160920420940313",
"31035053229546199656252032972759319953190362094566672920420940313"};
719 auto oss = ostringstream();
720 for(
int i = 1; i <= n; i++) {
723 const string str = oss.str();
725 for(
const char ch: str) {
740 s += 1.0 /
static_cast<double>(n++);
748 unsigned int coin = 0;
749 unsigned current = 1;
752 for(
unsigned int i = 0; i < k; i++) {
767 unsigned int ans = 0;
768 for(
unsigned int i = 1; i <= n; i++) {
777 unsigned int sum = 0;
780 for(
unsigned int i = 2; i <= l; i++) {
782 for(
unsigned int j = 2; j <= sqrt(i); j++) {
798 cout << count << endl;
806 auto palindromes = set<unsigned int>();
807 if(a <= 2 && 2 <= b) {
808 palindromes.insert(2);
810 if(a <= 10 && b >= 0) {
811 for(
unsigned int d1 = 3; d1 <= 9; d1 += 2) {
813 unsigned int palindrome = d1;
814 if(a <= palindrome && palindrome <= b) {
815 palindromes.insert(palindrome);
819 if(a <= 100 && b >= 10) {
820 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
822 unsigned int palindrome = d1 * 10 + d1;
823 if(a <= palindrome && palindrome <= b) {
824 palindromes.insert(palindrome);
828 if(a <= 1000 && b >= 100) {
829 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
831 for(
unsigned int d2 = 0; d2 <= 9; d2++) {
832 unsigned int palindrome = d1 * 100 + d2 * 10 + d1;
833 if(a <= palindrome && palindrome <= b) {
834 palindromes.insert(palindrome);
839 if(a <= 10000 && b >= 1000) {
840 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
842 for(
unsigned int d2 = 0; d2 <= 9; d2++) {
843 unsigned int palindrome = d1 * 1000 + d2 * 100 + d2 * 10 + d1;
844 if(a <= palindrome && palindrome <= b) {
845 palindromes.insert(palindrome);
850 if(a <= 100000 && b >= 10000) {
851 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
853 for(
unsigned int d2 = 0; d2 <= 9; d2++) {
854 for(
unsigned int d3 = 0; d3 <= 9; d3++) {
855 unsigned int palindrome = d1 * 10000 + 1000 * d2 + 100 * d3 + 10 * d2 + d1;
856 if(a <= palindrome && palindrome <= b) {
857 palindromes.insert(palindrome);
863 if(a <= 1000000 && b >= 100000) {
864 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
866 for(
unsigned int d2 = 0; d2 <= 9; d2++) {
867 for(
unsigned int d3 = 0; d3 <= 9; d3++) {
868 unsigned int palindrome = d1 * 100000 + d2 * 10000 + d3 * 1000 + d3 * 100 + d2 * 10 + d1;
869 if(a <= palindrome && palindrome <= b) {
870 palindromes.insert(palindrome);
876 if(a <= 10000000 && b >= 1000000) {
877 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
879 for(
unsigned int d2 = 0; d2 <= 9; d2++) {
880 for(
unsigned int d3 = 0; d3 <= 9; d3++) {
881 for(
unsigned int d4 = 0; d4 <= 9; d4++) {
882 unsigned int palindrome = d1 * 1000000 + d2 * 100000 + d3 * 10000 + d4 * 1000 + d3 * 100 + d2 * 10 + d1;
883 if(a <= palindrome && palindrome <= b) {
884 palindromes.insert(palindrome);
891 if(a <= 100000000 && b >= 10000000) {
892 for(
unsigned int d1 = 1; d1 <= 9; d1 += 2) {
894 for(
unsigned int d2 = 0; d2 <= 9; d2++) {
895 for(
unsigned int d3 = 0; d3 <= 9; d3++) {
896 for(
unsigned int d4 = 0; d4 <= 9; d4++) {
897 unsigned int palindrome = d1 * 10000000 + d2 * 1000000 + d3 * 100000 + d4 * 10000 + d4 * 1000 + d3 * 100 + d2 * 10 + d1;
898 if(a <= palindrome && palindrome <= b) {
899 palindromes.insert(palindrome);
906 for(
const auto palindrome: palindromes) {
908 for(
unsigned int i = 3; i <= sqrt(palindrome); i++) {
909 if(palindrome % i == 0) {
915 cout << palindrome << endl;
925 for(
int i = 1; sn < x; i++) {
926 sn = 100 * (1 - pow(0.98, i));
936 bool negative =
false;
959 cout << fixed << setprecision(2) << (pow((1 + sqrt(5)) / 2, n) - pow((1 - sqrt(5)) / 2, n)) / sqrt(5);
967 unsigned int maximum = 0;
968 unsigned int minimum = 1000;
969 for(
unsigned short i = 0; i < n; i++) {
971 maximum = max(maximum, a);
972 minimum = min(minimum, a);
974 cout << maximum - minimum;
984 unsigned int len = 1;
985 unsigned int ans = 1;
986 for(
unsigned int i = 1; i < n; i++, prev = a, ans = max(ans, len)) {
1001 for(
int i = 2; i <= sqrt(n); i++) {
1013 for(
int i = 0; i < n; i++) {
1014 for(
int j = 0; j < n; j++) {
1015 cout << setw(2) << setfill(
'0') <<
right << i * n + j + 1;
1021 for(
int i = 0; i < n; i++) {
1022 for(
int j = 0; j < n - i - 1; j++) {
1025 for(
int j = 0; j < i + 1; j++) {
1026 cout << setw(2) << setfill(
'0') <<
right << count++;
1036 for(
int k = 1; 1092 * k <= n; k++) {
1037 if((n - 1092 * k) % 364 == 0) {
1038 const int x = (n - 1092 * k) / 364;
1039 if(x < 1 || 100 < x) {
1057 for(
int i = 0; i < n; i++) {
1060 maximum = max(maximum, score);
1061 minimum = min(minimum, score);
1065 cout << fixed << setprecision(2) << static_cast<double>(sum) / (n - 2);
1073 for(
int i = 0; i < 12; i++) {
1076 if(current < budget) {
1081 saving += current / 100 * 100;
1084 cout << current + saving / 5 * 6;
1092 auto *fish =
new int[n];
1093 for(
int i = 0; i < n; i++) {
1096 for(
int i = 0; i < n; i++) {
1098 for(
int j = 0; j < i; j++) {
1099 if(fish[j] < fish[i]) {
1103 cout << count <<
" ";
1111 auto vec = vector<unsigned int>();
1119 for(
auto i =
vec.rbegin(); i !=
vec.rend(); ++i) {
1128 auto vec = vector<int>();
1138 for(
auto i =
vec.rbegin(); i !=
vec.rend(); ++i) {
1148 auto *tree =
new bool[l + 1];
1149 memset(tree, 1, (l + 1) *
sizeof(
bool));
1150 for(
int i = 0; i < m; i++) {
1154 for(
int j = u; j <= v; j++) {
1159 for(
int i = 0; i <= l; i++) {
1172 auto *students =
new int *[n];
1173 for(
int i = 0; i < n; i++) {
1174 students[i] =
new int[3];
1175 cin >> students[i][0] >> students[i][1] >> students[i][2];
1178 for(
int i = 0; i + 1 < n; i++) {
1180 for(
int k = 0; k < 3; k++) {
1181 sum_i += students[i][k];
1183 for(
int j = i + 1; j < n; j++) {
1186 for(
int k = 0; k < 3; k++) {
1187 sum_j += students[j][k];
1188 if(abs(students[i][k] - students[j][k]) > 5) {
1193 if(flag && abs(sum_i - sum_j) <= 10) {
1199 for(
int i = 0; i < n; i++) {
1200 delete[] students[i];
1211 bool block[21][21][21] = {};
1212 memset(block, 1,
sizeof block);
1222 cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
1223 for(
int i = x1; i <= x2; i++) {
1224 for(
int j = y1; j <= y2; j++) {
1225 for(
int k = z1; k <= z2; k++) {
1226 block[i][j][k] =
false;
1232 for(
int i = 1; i <= w; i++) {
1233 for(
int j = 1; j <= x; j++) {
1234 for(
int k = 1; k <= h; k++) {
1235 if(block[i][j][k]) {
1248 bool winning_numbers[34];
1249 memset(winning_numbers, 0,
sizeof winning_numbers);
1250 int prize_numbers[7];
1251 memset(prize_numbers, 0,
sizeof prize_numbers);
1252 for(
int i = 0; i < 7; i++) {
1254 cin >> winning_number;
1255 winning_numbers[winning_number] =
true;
1257 for(
int i = 0; i < n; i++) {
1258 int prize_number = 7;
1259 for(
int j = 0; j < 7; j++) {
1261 cin >> lottery_number;
1262 if(winning_numbers[lottery_number]) {
1266 prize_numbers[prize_number]++;
1268 for(
int i = 0; i < 7; i++) {
1269 cout << prize_numbers[i] <<
" ";
1277 memset(square, 0,
sizeof square);
1278 auto um = unordered_map<int, pair<int, int>>();
1280 square[0][n / 2] = 1;
1281 um[1] = make_pair(0, n / 2);
1282 for(
int k = 2; k <= n * n; k++) {
1283 auto [prev_x, prev_y] = um[k - 1];
1284 if(prev_x == 0 && prev_y != n - 1) {
1286 square[n - 1][prev_y + 1] = k;
1287 um[k] = make_pair(n - 1, prev_y + 1);
1288 }
else if(prev_y == n - 1 && prev_x != 0) {
1290 square[prev_x - 1][0] = k;
1291 um[k] = make_pair(prev_x - 1, 0);
1292 }
else if(prev_x == 0 && prev_y == n - 1) {
1294 square[1][prev_y] = k;
1295 um[k] = make_pair(1, prev_y);
1296 }
else if(prev_x != 0 && prev_y != n - 1) {
1298 if(square[prev_x - 1][prev_y + 1] == 0) {
1299 square[prev_x - 1][prev_y + 1] = k;
1300 um[k] = make_pair(prev_x - 1, prev_y + 1);
1302 square[prev_x + 1][prev_y] = k;
1303 um[k] = make_pair(prev_x + 1, prev_y);
1307 for(
int i = 0; i < n; i++) {
1308 for(
int j = 0; j < n; j++) {
1309 cout << square[i][j] <<
" ";
1319 char screen[5][400];
1320 memset(screen,
'.',
sizeof screen);
1321 const char nums[10][5][3] = {
1372 for(
int i = 0; i < n; i++) {
1376 for(
int j = 0; j < 5; j++) {
1377 for(
int k = 0; k < 3; k++) {
1378 screen[j][k + i * 4] = nums[num][j][k];
1382 for(
int i = 0; i < 5; i++) {
1383 for(
int j = 0; j < 4 * n - 1; j++) {
1384 cout << screen[i][j];
1396 auto ss = stringstream();
1397 for(
int i = m; i <= n; i++) {
1404 for(
int i = 0; i < 10; i++) {
1405 cout << nums[i] <<
" ";
1413 auto s = set<int>();
1414 for(
int i = 0; i < n; i++) {
1420 for(
auto i = s.begin(); i != s.end(); ++i) {
1421 for(
auto j = s.begin(); j != i; ++j) {
1423 if(sub != *j && s.contains(sub)) {
1437 auto *a =
new int[n];
1438 for(
int i = 0; i < n; i++) {
1442 for(
int i = 0; i + m <= n; i++) {
1444 for(
int j = i; j < i + m; j++) {
1447 ans = min(ans, sum);
1458 cin >> s1 >> s2 >> s3;
1459 const int n = s1 + s2 + s3 + 1;
1460 auto *sum =
new int[n];
1461 memset(sum, 0, n *
sizeof(
int));
1462 for(
int i = 1; i <= s1; i++) {
1463 for(
int j = 1; j <= s2; j++) {
1464 for(
int k = 1; k <= s3; k++) {
1471 for(
int i = 3; i < n; i++) {
1472 if(maximum < sum[i]) {
1484 auto *lamp =
new bool[2000001];
1485 memset(lamp, 0, 2000001 *
sizeof(
bool));
1487 for(
int i = 0; i < n; i++) {
1491 for(
int j = 1; j <= t; j++) {
1492 const int at = a * j;
1493 lamp[at] = !lamp[at];
1496 for(
int i = 0; i < 2000001; i++) {
1509 int square[9][9] = {};
1513 for(
int i = 1; i <= n * n; i++) {
1514 square[current_x][current_y] = i;
1515 auto [next_x, next_y] =
move_forward(dir, current_x, current_y);
1516 if(next_x < 0 || next_x >= n || next_y < 0 || next_y >= n || square[next_x][next_y] != 0) {
1517 dir = (dir + 1) % 4;
1519 const auto next =
move_forward(dir, current_x, current_y);
1520 current_x = next.first;
1521 current_y = next.second;
1523 for(
int i = 0; i < n; i++) {
1524 for(
int j = 0; j < n; j++) {
1525 cout << setw(3) <<
right << setfill(
' ') << square[i][j];
1533 int next_x = current_x;
1534 int next_y = current_y;
1549 return make_pair(next_x, next_y);
1555 auto *triangle =
new int *[n];
1556 for(
int i = 0; i < n; i++) {
1557 triangle[i] =
new int[i + 1];
1558 for(
int j = 0; j <= i; j++) {
1559 if(j == 0 || j == i) {
1562 triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
1564 cout << triangle[i][j] <<
" ";
1568 for(
int i = 0; i < n; i++) {
1569 delete[] triangle[i];
1580 bool space[101][101] = {};
1581 memset(space, 0,
sizeof space);
1582 for(
int i = 0; i < m; i++) {
1586 pair<int, int> lights[13] = {
1587 make_pair(x - 2, y),
1588 make_pair(x - 1, y - 1),
1589 make_pair(x - 1, y),
1590 make_pair(x - 1, y + 1),
1591 make_pair(x, y - 2),
1592 make_pair(x, y - 1),
1594 make_pair(x, y + 1),
1595 make_pair(x, y + 2),
1596 make_pair(x + 1, y - 1),
1597 make_pair(x + 1, y),
1598 make_pair(x + 1, y + 1),
1599 make_pair(x + 2, y),
1601 for(
auto [light_x, light_y]: lights) {
1602 if(0 < light_x && light_x <= n && 0 < light_y && light_y <= n) {
1603 space[light_x][light_y] =
true;
1607 for(
int i = 0; i < k; i++) {
1611 for(
int light_x = o - 2; light_x <= o + 2; light_x++) {
1612 for(
int light_y = p - 2; light_y <= p + 2; light_y++) {
1613 if(0 < light_x && light_x <= n && 0 < light_y && light_y <= n) {
1614 space[light_x][light_y] =
true;
1620 for(
int i = 1; i <= n; i++) {
1621 for(
int j = 1; j <= n; j++) {
1636 for(
int i = 0; i < n * n; i++) {
1647 if((i + 1) % n == 0) {
1661 if(isdigit(ch) == 0) {
1665 if(ch -
'0' == current) {
1668 ans.push_back(count);
1669 current = (current + 1) % 2;
1673 ans.push_back(count);
1674 cout << static_cast<int>(sqrt(n)) <<
" ";
1675 for(
const auto i: ans) {
1685 auto *start =
new char *[n];
1686 auto *end =
new char *[n];
1687 for(
int i = 0; i < n; i++) {
1688 start[i] =
new char[n];
1689 for(
int j = 0; j < n; j++) {
1693 for(
int i = 0; i < n; i++) {
1694 end[i] =
new char[n];
1695 for(
int j = 0; j < n; j++) {
1699 auto *
const r90 =
rorate90(n, start);
1702 auto *
const r =
reflect(n, start);
1703 auto *
const rr90 =
reflect(n, r90);
1704 auto *
const rr180 =
reflect(n, r180);
1705 auto *
const rr270 =
reflect(n, r270);
1706 if(
equal(n, r90, end)) {
1708 }
else if(
equal(n, r180, end)) {
1710 }
else if(
equal(n, r270, end)) {
1712 }
else if(
equal(n, r, end)) {
1714 }
else if(
equal(n, rr90, end)) {
1716 }
else if(
equal(n, rr180, end)) {
1718 }
else if(
equal(n, rr270, end)) {
1720 }
else if(
equal(n, start, end)) {
1726 for(
int i = 0; i < n; i++) {
1750 auto *
const cpy =
new char *[n];
1751 for(
int i = 0; i < n; i++) {
1752 cpy[i] =
new char[n];
1754 for(
int i1 = 0, j2 = 0; i1 < n && j2 < n; i1++, j2++) {
1755 for(
int j1 = 0, i2 = n - 1; j1 < n && i2 >= 0; j1++, i2--) {
1756 cpy[i1][j1] = start[i2][j2];
1763 auto *
const cpy =
new char *[n];
1764 for(
int i = 0; i < n; i++) {
1765 cpy[i] =
new char[n];
1767 for(
int i1 = 0, i2 = n - 1; i1 < n && i2 >= 0; i1++, i2--) {
1768 for(
int j1 = 0, j2 = n - 1; j1 < n && j2 >= 0; j1++, j2--) {
1769 cpy[i1][j1] = start[i2][j2];
1776 auto *
const cpy =
new char *[n];
1777 for(
int i = 0; i < n; i++) {
1778 cpy[i] =
new char[n];
1780 for(
int i1 = 0, j2 = n - 1; i1 < n && j2 >= 0; i1++, j2--) {
1781 for(
int j1 = 0, i2 = 0; j1 < n && i2 < n; j1++, i2++) {
1782 cpy[i1][j1] = start[i2][j2];
1789 auto *
const cpy =
new char *[n];
1790 for(
int i = 0; i < n; i++) {
1791 cpy[i] =
new char[n];
1793 for(
int i1 = 0, i2 = 0; i1 < n && i2 < n; i1++, i2++) {
1794 for(
int j1 = 0, j2 = n - 1; j1 < n && j2 >= 0; j1++, j2--) {
1795 cpy[i1][j1] = start[i2][j2];
1802 for(
int i = 0; i < n; i++) {
1803 for(
int j = 0; j < n; j++) {
1804 if(start[i][j] != end[i][j]) {
1815 for(
const char ch: str) {
1816 if(islower(ch) != 0) {
1817 cout << static_cast<char>(toupper(ch));
1829 for(
const char ch: str) {
1830 cout << static_cast<char>((ch -
'a' + n) % 26 +
'a');
1841 for(
const char ch: str) {
1844 for(
int i = 0; i < 26; i++) {
1846 maxn = max(maxn, freq[i]);
1847 minn = min(minn, freq[i]);
1851 for(
int i = 2; i <= sqrt(maxn - minn); i++) {
1852 if((maxn - minn) % i == 0) {
1857 if(maxn - minn < 2) {
1861 cout <<
"Lucky Word" << endl
1864 cout <<
"No Answer" << endl
1875 for(
int _ = 0; _ < i; _++) {
1880 if(isalpha(pos1[0]) != 0) {
1882 cin >> num1 >> num2;
1884 auto ss = stringstream();
1889 auto oss = ostringstream();
1892 oss << num1 <<
'+' << num2 <<
'=' << num1 + num2;
1895 oss << num1 <<
'-' << num2 <<
'=' << num1 - num2;
1898 oss << num1 <<
'*' << num2 <<
'=' << num1 * num2;
1901 cerr <<
"Unknown Op:\t" << op;
1904 string str = oss.str();
1906 << str.length() << endl;
1914 while((ch = cin.get()) != EOF) {
1915 if(isalnum(ch) != 0) {
1928 for(
int i = 0; i < n; i++) {
1934 doc.insert(doc.end(), str.begin(), str.end());
1935 cout << doc << endl;
1942 doc = doc.substr(a, b);
1943 cout << doc << endl;
1950 doc.insert(doc.begin() + a, str.begin(), str.end());
1951 cout << doc << endl;
1957 const auto ans = doc.find(str);
1958 if(ans == string::npos) {
1961 cout << ans << endl;
1973 auto *target =
new char[11];
1974 auto *article =
new char[1000001];
1975 cin.getline(target, 11);
1976 for(
int i = 0; i < strlen(target); i++) {
1977 target[i] = tolower(target[i]);
1979 cin.getline(article, 1000001);
1981 for(
int i = 0; i + strlen(target) <= strlen(article); i++) {
1982 if(!((i == 0 || article[i - 1] ==
' ') && (i + strlen(target) == strlen(article) || article[i + strlen(target)] ==
' '))) {
1986 for(
int j = 0; j < strlen(target); j++) {
1987 if(target[j] != tolower(article[i + j])) {
2002 cout << sum <<
" " << pos;
2011 const int nums[26] = {1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4};
2013 while((ch = cin.get()) != EOF) {
2016 }
else if(isalpha(ch) != 0) {
2017 ans += nums[ch -
'a'];
2031 for(
int i = 0; i < n - 1; i++) {
2033 if(str[i + 1] ==
'K') {
2035 }
else if(i + 2 == n || i + 2 < n && str[i + 2] !=
'K') {
2038 }
else if(str[i + 1] ==
'K' && (i - 1 >= 0 && str[i - 1] !=
'V' || i == 0)) {
2051 string boygirl[] = {
"boy",
"girl"};
2053 for(
auto word: boygirl) {
2055 for(
int i = 0; i + word.length() - 1 < str.length(); i++) {
2056 for(
int j = 0; j < word.length(); j++) {
2057 if(word[j] == str[i + j]) {
2063 cout << count << endl;
2076 if(isdigit(ch) != 0) {
2078 dq[current].push_front(ch);
2084 if(op ==
'.' || op ==
'/') {
2087 for(
int i = 0; i < limit; i++) {
2088 while(dq[i].size() > 1 && dq[i].front() ==
'0') {
2091 if(op ==
'.' && i == 1) {
2092 while(dq[i].size() > 1 && dq[i].back() ==
'0') {
2096 while(!dq[i].empty()) {
2097 ss[i] << dq[i].front();
2101 cout << ss[0].str();
2105 cout << ss[1].str();
2112 unordered_map<string, int> um;
2125 um[
"thirteen"] = 13;
2126 um[
"fourteen"] = 14;
2129 um[
"seventeen"] = 17;
2130 um[
"eighteen"] = 18;
2131 um[
"nineteen"] = 19;
2141 for(
int i = 0; i < 6; i++) {
2143 if(um.contains(word)) {
2144 ms.insert(um[word] * um[word] % 100);
2152 for(
const auto i:
ms) {
2158 unsigned long long ans;
2167 cin >> comet >> team;
2168 unsigned int comet_int = 1;
2169 unsigned int team_int = 1;
2170 for(
const char ch: comet) {
2171 comet_int *= ch -
'A' + 1;
2174 for(
const char ch: team) {
2175 team_int *= ch -
'A' + 1;
2178 cout << (comet_int == team_int ?
"GO" :
"STAY");
2191 if(!(cin >> var) || isalpha(var) == 0) {
2207 if(isdigit(cin.peek()) != 0) {
2227 cout << a <<
" " << b <<
" " << c;
2236 if(isupper(ch) != 0) {
2238 maximum = max(maximum, count[ch -
'A']);
2241 for(
int i = maximum; i > 0; i--) {
2242 for(
int j = 0; j < 26; j++) {
2252 for(
char ch =
'A'; ch <=
'Z'; ch++) {
2265 cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
2266 const double d12 = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
2267 const double d23 = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
2268 const double d13 = sqrt(pow(x3 - x1, 2) + pow(y3 - y1, 2));
2269 cout << fixed << setprecision(2) << d12 + d23 + d13;
2276 bool notprime[100001];
2277 memset(notprime, 1,
sizeof notprime);
2278 notprime[0] =
false;
2279 notprime[1] =
false;
2281 for(
unsigned int i = 2; i <= 50000; i++) {
2282 for(
unsigned int j = 2; i * j <= 100000; j++) {
2283 notprime[i * j] =
false;
2287 for(
int _ = 0; _ < n; _++) {
2302 for(
int year = x; year <= y; year++) {
2303 if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
2318 for(
int i = 0; i < n; i++) {
2320 for(
int j = 0; j < m; j++) {
2323 sort(
vec.begin(),
vec.end());
2324 ans = max(ans,
static_cast<double>(accumulate(
vec.begin() + 1,
vec.end() - 1, 0)) / (m - 2));
2326 cout << fixed << setprecision(2) << ans;
2333 unsigned int ans = 1;
2334 for(
unsigned int i = 1; i <= n; i++) {
2345 auto *
const matrix =
new bool *[n];
2346 for(
int i = 0; i < n; i++) {
2347 matrix[i] =
new bool[n];
2348 memset(matrix[i], 1, n *
sizeof(
bool));
2351 for(
int i = 0; i < n; i++) {
2352 for(
int j = 0; j < n; j++) {
2353 cout << matrix[i][j] <<
" ";
2364 matrix[x0][y0] =
false;
2367 for(
int i = 0; i < n / 2; i++) {
2368 for(
int j = 0; j < n / 2; j++) {
2369 matrix[x0 + i][y0 + j] =
false;
2372 pardon(matrix, x0, y0 + n / 2, n / 2);
2373 pardon(matrix, x0 + n / 2, y0, n / 2);
2374 pardon(matrix, x0 + n / 2, y0 + n / 2, n / 2);
2385 for(
int i = 0; i < n; i++) {
2390 cin >> name >> grade1 >> grade2 >> grade3;
2391 const int sum = grade1 + grade2 + grade3;
2400 cout << max_name <<
' ' << max_1 <<
' ' << max_2 <<
' ' << max_3;
2407 vector<pair<string, array<int, 3>>>
vec(n);
2408 for(
int i = 0; i < n; i++) {
2410 array<int, 3> grade = {};
2411 cin >> name >> grade[0] >> grade[1] >> grade[2];
2412 vec[i] = make_pair(name, grade);
2414 for(
int i = 0; i + 1 < n; i++) {
2415 const int sum_i =
vec[i].second[0] +
vec[i].second[1] +
vec[i].second[2];
2416 for(
int j = i + 1; j < n; j++) {
2417 const int sum_j =
vec[j].second[0] +
vec[j].second[1] +
vec[j].second[2];
2418 if(abs(sum_i - sum_j) <= 10) {
2420 for(
int k = 0; k < 3; k++) {
2421 if(abs(
vec[i].second[k] -
vec[j].second[k]) > 5) {
2427 cout <<
vec[i].first <<
' ' <<
vec[j].first << endl;
2439 for(
int i = 0; i < n; i++) {
2446 auto s =
Student(number, grade, extra_grade);
2447 cout << (s.excellent() ?
"Excellent" :
"Not excellent") << endl;
2459 for(
int i = 2; i <= n; i++) {
2462 for(
int i = 2; i <= n; i++) {
2463 for(
int j = 2; i * j <= n; j++) {
2464 primes.erase(i * j);
2467 for(
int i = 4; i <= n; i += 2) {
2468 for(
auto prime = primes.begin(); *prime <= i / 2 && prime != primes.end(); ++prime) {
2469 if(primes.contains(i - *prime)) {
2470 cout << i <<
'=' << *prime <<
'+' << i - *prime << endl;
2484 const int n =
vec.size();
2485 const unsigned long long base =
static_cast<unsigned long long>(1) << n - 1;
2486 unsigned long long sum = 0;
2487 for(
const auto num:
vec) {
2498 for(
int i = 0; i < n - 1; i++) {
2510 for(
int i = 0; i < n; i++) {
2516 cout << stu.name <<
' ' << stu.age <<
' ' << stu.grade << endl;
int main(int argc, char **argv)
void ms(vector< int > &arr, int l, int r, int *ans)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int gcd(int m, int n)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static pair< int, int > move_forward(int dir, int current_x, int current_y)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static char ** rorate90(int n, char **start)
static bool equal(int n, char **start, char **end)
static char ** rorate180(int n, char **start)
static char ** reflect(int n, char **start)
static char ** rorate270(int n, char **start)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static void pardon(bool **matrix, int x0, int y0, int n)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
bool excellent() const
学生是否优秀
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)
static int main(istream &cin, ostream &cout)