buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <stdio.h> int main(void) { int m, d, i; int W; int s = 0; while (1) { s = 0; scanf("%d %d", &m, &d); if (m == 0 || d == 0) break; for (i = 1; i < m; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) s += 31; else if (i == 4 || i == 6 || i == 9 || i == 11) s += 30; else if (i == 2) s += 29; } s = s + d; if (s % 7 == 0) printf("Wednesay\n"); else if (s % 7 == 1) printf("Thursday\n"); else if (s % 7 == 2) printf("Friday\n"); else if (s % 7 == 3) printf("Saturday\n"); else if (s % 7 == 4) printf("Sunday\n"); else if (s % 7 == 5) printf("Monday\n"); else if (s % 7 == 6) printf("Tuesday\n"); } return 0; }
#include <stdio.h> int main(void) { int m, d, i; int W; int s; while (1) { s = 0; scanf("%d %d", &m, &d); if (m == 0 || d == 0) break; for (i = 1; i < m; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) s += 31; else if (i == 4 || i == 6 || i == 9 || i == 11) s += 30; else if (i == 2) s += 29; } s = s + d; if (s % 7 == 0) printf("Wednesday\n"); else if (s % 7 == 1) printf("Thursday\n"); else if (s % 7 == 2) printf("Friday\n"); else if (s % 7 == 3) printf("Saturday\n"); else if (s % 7 == 4) printf("Sunday\n"); else if (s % 7 == 5) printf("Monday\n"); else if (s % 7 == 6) printf("Tuesday\n"); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
269
4
#include <stdio.h> int main(void) { int month, day; int sum; int i; scanf("%d %d", &month, &day); while (month != 0) { sum = 0; for (i = 1; i < month; i++) { switch (i) { case 2: sum = sum + 29; break; case 4: sum = sum + 30; break; case 6: sum = sum + 30; break; case 9: sum = sum + 30; break; case 11: sum = sum + 30; break; default: sum = sum + 31; break; } } sum = sum + day; switch (sum % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Thuesday\n"); break; } scanf("%d %d", &month, &day); } return 0; }
#include <stdio.h> int main() { int month, day; int sum; int i; scanf("%d %d", &month, &day); while (month != 0) { sum = 0; for (i = 1; i < month; i++) { switch (i) { case 2: sum = sum + 29; break; case 4: sum = sum + 30; break; case 6: sum = sum + 30; break; case 9: sum = sum + 30; break; case 11: sum = sum + 30; break; default: sum = sum + 31; break; } } sum = sum + day; switch (sum % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } scanf("%d %d", &month, &day); } return 0; }
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
252
3
#include <stdio.h> int main() { while (1) { int i, j, d, m, All = 0; scanf("%d%d", &m, &d); if (m == 0 && d == 0) break; j = m - 1; for (i = j; i > 0; i--) { if (i == 1 || i == 3 || i == 4 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { All += 31; } else if (i == 4 || i == 6 || i == 9 || i == 11) { All += 30; } else if (i == 2) { All += 29; } } All += d; if (All % 7 == 1) printf("Thursday\n"); if (All % 7 == 2) printf("Friday\n"); if (All % 7 == 3) printf("Saturday\n"); if (All % 7 == 4) printf("Sunday\n"); if (All % 7 == 5) printf("Monday\n"); if (All % 7 == 6) printf("Tuesday\n"); if (All % 7 == 0) printf("Wednesday\n"); } return 0; }
#include <stdio.h> int main() { while (1) { int i, j, d, m, All = 0; scanf("%d%d", &m, &d); if (m == 0 && d == 0) break; j = m - 1; for (i = j; i > 0; i--) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { All += 31; } else if (i == 4 || i == 6 || i == 9 || i == 11) { All += 30; } else if (i == 2) { All += 29; } } All += d; if (All % 7 == 1) printf("Thursday\n"); if (All % 7 == 2) printf("Friday\n"); if (All % 7 == 3) printf("Saturday\n"); if (All % 7 == 4) printf("Sunday\n"); if (All % 7 == 5) printf("Monday\n"); if (All % 7 == 6) printf("Tuesday\n"); if (All % 7 == 0) printf("Wednesday\n"); } return 0; }
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 106], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 60]]
0
270
4
#include <stdio.h> const char week[7][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; const int days[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main(void) { int i, m, d; while (~scanf("%d %d", &m, &d)) { for (i = 1; i < m; i++) { d += days[i]; } printf("%s\n", week[d % 7]); } return 0; }
#include <stdio.h> const char week[7][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; const int days[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main(void) { int i, m, d; while (~scanf("%d %d", &m, &d), m) { for (i = 1; i < m; i++) { d += days[i]; } printf("%s\n", week[d % 7]); } return 0; }
[["+", 8, 9, 0, 52, 15, 23, 0, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 23, 0, 34, 12, 22]]
0
149
2
#include <stdio.h> int main(void) { int m, d, w; char week[20][20] = {"Wednesday", "Thursday", "Fryday", "Saturday", "Sunday", "Monday", "Tuesday"}; while (1) { scanf("%d %d", &m, &d); if (m == 0) break; w = d % 7; switch (m) { case 2: w = (w + 3) % 7; break; case 3: w = (w + 4) % 7; break; case 5: w = (w + 2) % 7; break; case 6: w = (w + 5) % 7; break; case 8: w = (w + 3) % 7; break; case 9: w = (w + 6) % 7; break; case 10: w = (w + 1) % 7; break; case 11: w = (w + 4) % 7; break; case 12: w = (w + 6) % 7; break; default: break; } printf("%s\n", week[w]); } return (0); }
#include <stdio.h> int main(void) { int m, d, w; char week[20][20] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; while (1) { scanf("%d %d", &m, &d); if (m == 0) break; w = d % 7; switch (m) { case 2: w = (w + 3) % 7; break; case 3: w = (w + 4) % 7; break; case 5: w = (w + 2) % 7; break; case 6: w = (w + 5) % 7; break; case 8: w = (w + 3) % 7; break; case 9: w = (w + 6) % 7; break; case 10: w = (w + 1) % 7; break; case 11: w = (w + 4) % 7; break; case 12: w = (w + 6) % 7; break; default: break; } printf("%s\n", week[w]); } return (0); }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
251
2
#include <stdio.h> int main(void) { int n, j, m, day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d", &n); scanf("%d", &j); if (n == 0 && j == 0) break; for (m = 1; m < n; m++) { j = j + day[m - 1]; } j = j % 7; if (j == 1) printf("Thursday\n"); else if (j == 2) printf("Friday\n"); else if (j == 3) printf("Saturday\n"); else if (j == 4) printf("Sunday\n"); else if (j == 5) printf("Monday\n"); else if (j == 6) printf("Tuseday\n"); else printf("Wednsday\n"); } return 0; }
#include <stdio.h> int main(void) { int n, j, m, day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d", &n); scanf("%d", &j); if (n == 0 && j == 0) break; for (m = 1; m < n; m++) { j = j + day[m - 1]; } j = j % 7; if (j == 1) printf("Thursday\n"); else if (j == 2) printf("Friday\n"); else if (j == 3) printf("Saturday\n"); else if (j == 4) printf("Sunday\n"); else if (j == 5) printf("Monday\n"); else if (j == 6) printf("Tuesday\n"); else printf("Wednesday\n"); } return 0; }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
218
4
#include <stdio.h> int main() { int month, date; int n; int i; int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char *weeks[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", }; while (1) { scanf("%d %d", &month, &date); if (month == 0) break; n = 0; for (i = 0; i < month - 1; i++) n += day[i]; printf("%s\n", weeks[(n + date) % 7 - 1]); } return 0; }
#include <stdio.h> int main() { int month, date; int n; int i; int day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char *weeks[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", }; while (1) { scanf("%d %d", &month, &date); if (month == 0) break; n = 0; for (i = 0; i < month - 1; i++) n += day[i]; printf("%s\n", weeks[(n + date - 1) % 7]); } return 0; }
[["+", 0, 69, 71, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 69, 71, 16, 31, 23, 0, 16, 12, 13], ["-", 0, 2, 3, 4, 0, 69, 71, 16, 17, 33], ["-", 0, 2, 3, 4, 0, 69, 71, 16, 12, 13]]
0
166
4
#include <stdio.h> int main(void) { int hi[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int i, t, n, ni; while (1) { ni = 0; scanf("%d %d", &t, &n); if (t == 0) break; for (i = 2; i <= t; i++) { ni += hi[i - 1]; } ni = ni + n + 3; if (ni % 7 == 0) { printf("Sunday\n"); } if (ni % 7 == 1) { printf("Monday\n"); } if (ni % 7 == 2) { printf("Tuesday\n"); } if (ni % 7 == 3) { printf("Wednesday\n"); } if (ni % 7 == 4) { printf("Thursday\n"); } if (ni % 7 == 5) { printf("Friday\n"); } if (ni % 7 == 6) { printf("saturday\n"); } } return 0; }
#include <stdio.h> int main(void) { int hi[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int i, t, n, ni; while (1) { ni = 0; scanf("%d %d", &t, &n); if (t == 0) break; for (i = 2; i <= t; i++) { ni += hi[i - 1]; } ni = ni + n + 3; if (ni % 7 == 0) { printf("Sunday\n"); } if (ni % 7 == 1) { printf("Monday\n"); } if (ni % 7 == 2) { printf("Tuesday\n"); } if (ni % 7 == 3) { printf("Wednesday\n"); } if (ni % 7 == 4) { printf("Thursday\n"); } if (ni % 7 == 5) { printf("Friday\n"); } if (ni % 7 == 6) { printf("Saturday\n"); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
244
2
#include <stdio.h> #define buf 400 int main() { int month[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; int x, y, i, j, n; int year[buf]; char str[buf]; for (;;) { fgets(str, sizeof(str), stdin); sscanf(str, "%d %d", &x, &y); if (x == 0 && y == 0) break; for (i = 0; i <= 400; i += 7) { for (j = 1; j <= 7; j++) { year[j + i] = j; } } for (i = 0; i < x; i++) n = month[i]; n = year[n + y]; switch (n) { case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; case 7: printf("Wednesday\n"); break; } } return 0; }
#include <stdio.h> #define buf 400 int main() { int month[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; int x, y, i, j, n; int year[buf]; char str[buf]; for (;;) { n = 0; fgets(str, sizeof(str), stdin); sscanf(str, "%d %d", &x, &y); if (x == 0 && y == 0) break; for (i = 0; i <= 400; i += 7) { for (j = 1; j <= 7; j++) { year[j + i] = j; } } for (i = 0; i < x; i++) n += month[i]; n = year[n + y]; switch (n) { case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; case 7: printf("Wednesday\n"); break; } } return 0; }
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 7, 8, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 17, 107]]
0
281
6
#include <stdio.h> //????????????????????£?¨?????§? int days(int year, int day); void whatday(int day); //????????????????????£?¨??????? int main(void) { int year, day, total; while (1) { scanf("%d %d", &year, &day); if (year == 0 && day == 0) break; total = days(year, day); whatday(total); } return 0; } int days(int year, int day) { int k, total = day; switch (year) { case 12: total += 30; case 11: total += 31; case 10: total += 30; case 9: total += 31; case 8: total += 31; case 7: total += 30; case 6: total += 31; case 5: total += 30; case 4: total += 21; case 3: total += 29; case 2: total += 31; } return total; } void whatday(int day) { switch (day % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } }
#include <stdio.h> //????????????????????£?¨?????§? int days(int year, int day); void whatday(int day); //????????????????????£?¨??????? int main(void) { int year, day, total; while (1) { scanf("%d %d", &year, &day); if (year == 0 && day == 0) break; total = days(year, day); whatday(total); } return 0; } int days(int year, int day) { int k, total = day; switch (year) { case 12: total += 30; case 11: total += 31; case 10: total += 30; case 9: total += 31; case 8: total += 31; case 7: total += 30; case 6: total += 31; case 5: total += 30; case 4: total += 31; case 3: total += 29; case 2: total += 31; } return total; } void whatday(int day) { switch (day % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } }
[["-", 8, 9, 0, 100, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 100, 0, 1, 0, 11, 12, 13]]
0
294
2
#include <stdio.h> int main() { int i, k = 0, a, b, c[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d %d", &a, &b); if (a == 0) break; for (i = 0; i < a - 1; i++) k += c[i]; i = (k + b) % 7; switch (i) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
#include <stdio.h> int main() { int i, k, a, b, c[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { k = 0; scanf("%d %d", &a, &b); if (a == 0) break; for (i = 0; i < a - 1; i++) k += c[i]; i = (k + b) % 7; switch (i) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
209
6
m, s[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; main(d) { char a[7][9] = {"Thurs", "Fri", "Satur", "Sun", "Mon", "Tues", "Wednes"}; while (1) { scanf("%d%d", &m, &d); if (!m) exit(0); d += s[m - 1]; printf("%sday\n", &a[(!d % 7) ? 6 : (d % 7 - 1)][0]); } }
m, s[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; main(d) { char a[7][9] = {"Thurs", "Fri", "Satur", "Sun", "Mon", "Tues", "Wednes"}; while (1) { scanf("%d%d", &m, &d); if (!m) exit(0); d += s[m - 1]; printf("%sday\n", &a[(d % 7 == 0) ? 6 : (d % 7 - 1)][0]); } }
[["-", 71, 41, 15, 23, 0, 16, 31, 91, 17, 111], ["+", 28, 69, 71, 41, 15, 23, 0, 16, 17, 60], ["+", 28, 69, 71, 41, 15, 23, 0, 16, 12, 13]]
0
147
9
#include <stdio.h> int main() { int a, b, i, sum = 0, month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char ans[7][16] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (scanf("%d %d", &a, &b), a && b) { for (i = 0; i < a - 1; i++) sum += month[i]; sum += b - 1; printf("%s\n", &ans[sum % 7][0]); } return 0; }
#include <stdio.h> int main() { int a, b, i, sum, month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char ans[7][16] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (scanf("%d %d", &a, &b), a && b) { sum = 0; for (i = 0; i < a - 1; i++) sum += month[i]; sum += b - 1; printf("%s\n", &ans[sum % 7][0]); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
160
6
#include <stdio.h> int main(int argc, const char *argv[]) { int month, day, day_plus, i, word; int month_def[12]; month_def[0] = 31; month_def[1] = 29; month_def[2] = 31; month_def[3] = 30; month_def[4] = 31; month_def[5] = 30; month_def[6] = 31; month_def[7] = 31; month_def[8] = 30; month_def[9] = 31; month_def[10] = 30; month_def[11] = 31; while (scanf("%d%d", &month, &day)) { if (month == 0) { return 0; } day_plus = 0; for (i = 0; i < month - 1; i++) { day_plus += month_def[i]; } day_plus += day; word = day_plus % 7; switch (word) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sanday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; default: break; } } return 0; }
#include <stdio.h> int main(int argc, const char *argv[]) { int month, day, day_plus, i, word; int month_def[12]; month_def[0] = 31; month_def[1] = 29; month_def[2] = 31; month_def[3] = 30; month_def[4] = 31; month_def[5] = 30; month_def[6] = 31; month_def[7] = 31; month_def[8] = 30; month_def[9] = 31; month_def[10] = 30; month_def[11] = 31; while (scanf("%d%d", &month, &day)) { if (month == 0) { return 0; } day_plus = 0; for (i = 0; i < month - 1; i++) { day_plus += month_def[i]; } day_plus += day; word = day_plus % 7; switch (word) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; default: break; } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
288
2
#include <stdio.h> #define THU 0 #define FRI 1 #define SAT 2 #define SUN 3 #define MON 4 #define TUE 5 #define WED 6 int getDayFrom1_1(int month, int day) { int dayFrom1_1 = day - 1; if (month >= 2) { dayFrom1_1 += 31; } if (month >= 3) { dayFrom1_1 += 29; } if (month >= 4) { dayFrom1_1 += 31; } if (month >= 5) { dayFrom1_1 += 30; } if (month >= 6) { dayFrom1_1 += 31; } if (month >= 7) { dayFrom1_1 += 30; } if (month >= 8) { dayFrom1_1 += 31; } if (month >= 9) { dayFrom1_1 += 31; } if (month >= 10) { dayFrom1_1 += 30; } if (month >= 11) { dayFrom1_1 += 31; } if (month >= 12) { dayFrom1_1 += 30; } return dayFrom1_1; } int main(void) { int month, day; int day1; char y_str[7][10] = {"ThursDay", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (1) { scanf("%d%d", &month, &day); if (month == 0) { break; } day1 = getDayFrom1_1(month, day); puts(y_str[day1 % 7]); } return 0; }
#include <stdio.h> #define THU 0 #define FRI 1 #define SAT 2 #define SUN 3 #define MON 4 #define TUE 5 #define WED 6 int getDayFrom1_1(int month, int day) { int dayFrom1_1 = day - 1; if (month >= 2) { dayFrom1_1 += 31; } if (month >= 3) { dayFrom1_1 += 29; } if (month >= 4) { dayFrom1_1 += 31; } if (month >= 5) { dayFrom1_1 += 30; } if (month >= 6) { dayFrom1_1 += 31; } if (month >= 7) { dayFrom1_1 += 30; } if (month >= 8) { dayFrom1_1 += 31; } if (month >= 9) { dayFrom1_1 += 31; } if (month >= 10) { dayFrom1_1 += 30; } if (month >= 11) { dayFrom1_1 += 31; } if (month >= 12) { dayFrom1_1 += 30; } return dayFrom1_1; } int main(void) { int month, day; int day1; char y_str[7][10] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (1) { scanf("%d%d", &month, &day); if (month == 0) { break; } day1 = getDayFrom1_1(month, day); puts(y_str[day1 % 7]); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
281
2
#include <stdio.h> int main() { int mo, da, i, sda; // the list of the number of days in each month int dlist[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char dayname[7][9] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (1) { scanf("%d %d", &mo, &da); if (mo == 0) break; sda = 0; for (i = 0; i < (mo - 1); i++) { sda += dlist[i]; } printf("%s\n", dayname[(sda + da + 2) % 7]); } return 0; }
#include <stdio.h> int main() { int mo, da, i, sda; // the list of the number of days in each month int dlist[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char dayname[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (1) { scanf("%d %d", &mo, &da); if (mo == 0) break; sda = 0; for (i = 0; i < (mo - 1); i++) { sda += dlist[i]; } printf("%s\n", dayname[(sda + da + 2) % 7]); } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
0
170
2
#include <stdio.h> // 1:45 start // 1:56 compile //#define DEBUG char *day[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satday", "Sunday"}; int num_of_day[] = {31, 29, 31, 31, 31, 30, // Leap Year 31, 31, 30, 31, 30, 31}; char month_day[12][31]; void calc(void) { int cnt = 3; // 2004/1/1 is Thursday(3) int m, d; for (m = 0; m < 12; m++) { for (d = 0; d < num_of_day[m]; d++) { month_day[m][d] = cnt; cnt = (cnt == 7 - 1) ? 0 : cnt + 1; } } } int main(void) { FILE *fp; #ifdef DEBUG fp = fopen("input.txt", "r"); #else fp = stdin; #endif calc(); while (1) { int m, d; fscanf(fp, "%d %d\n", &m, &d); if (m == 0) { break; } printf("%s\n", day[month_day[m - 1][d - 1]]); } return 0; }
#include <stdio.h> // 1:45 start // 1:56 compile //#define DEBUG char *day[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int num_of_day[] = {31, 29, 31, 30, 31, 30, // Leap Year 31, 31, 30, 31, 30, 31}; char month_day[12][31]; void calc(void) { int cnt = 3; // 2004/1/1 is Thursday(3) int m, d; for (m = 0; m < 12; m++) { for (d = 0; d < num_of_day[m]; d++) { month_day[m][d] = cnt; cnt = (cnt == 7 - 1) ? 0 : cnt + 1; } } } int main(void) { FILE *fp; #ifdef DEBUG fp = fopen("input.txt", "r"); #else fp = stdin; #endif calc(); while (1) { int m, d; fscanf(fp, "%d %d\n", &m, &d); if (m == 0) { break; } printf("%s\n", day[month_day[m - 1][d - 1]]); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
0
258
4
#include <stdio.h> int main(void) { int i, j; int month, day; int daycount = 0; while (1) { daycount = 0; scanf("%d", &month); scanf("%d", &day); if ((month == 0) && (day == 0)) { return 0; } for (i = 1; i < month; i++) { if ((i == 11) || (i == 4) || (i == 6) || (i == 9)) { daycount += 30; } else if ((i == 1) || (i == 3) || (i == 5) || (i == 7) || (i == 8) || (i == 10) || (i == 12)) { daycount += 31; } else if (i == 2) { daycount += 29; } } daycount += day; daycount = daycount % 7; if (daycount == 0) { printf("Wednesday\n"); } else if (daycount == 1) { printf("Thursday\n"); } else if (daycount == 2) { printf("Friday\n"); } else if (daycount == 3) { printf("Saturday\n"); } else if (daycount == 4) { printf("Sanday\n"); } else if (daycount == 5) { printf("Monday\n"); } else if (daycount == 6) { printf("Tuesday\n"); } } return 0; }
#include <stdio.h> int main(void) { int i, j; int month, day; int daycount = 0; while (1) { daycount = 0; scanf("%d", &month); scanf("%d", &day); if ((month == 0) && (day == 0)) { return 0; } for (i = 1; i < month; i++) { if ((i == 11) || (i == 4) || (i == 6) || (i == 9)) { daycount += 30; } else if ((i == 1) || (i == 3) || (i == 5) || (i == 7) || (i == 8) || (i == 10) || (i == 12)) { daycount += 31; } else if (i == 2) { daycount += 29; } } daycount += day; daycount = daycount % 7; if (daycount == 0) { printf("Wednesday\n"); } else if (daycount == 1) { printf("Thursday\n"); } else if (daycount == 2) { printf("Friday\n"); } else if (daycount == 3) { printf("Saturday\n"); } else if (daycount == 4) { printf("Sunday\n"); } else if (daycount == 5) { printf("Monday\n"); } else if (daycount == 6) { printf("Tuesday\n"); } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
315
2
#include <math.h> #include <stdio.h> int p[10][10]; void drop(int x, int y) { if (-1 < x && x < 10 && -1 < y && y < 10) p[x][y]++; } int main(void) { int m, d; while (1) { scanf("%d %d", &m, &d); if (m == 0 && d == 0) break; switch (m) { case 2: d += 31; break; case 3: d += 60; break; case 4: d += 91; break; case 5: d += 121; break; case 6: d += 152; break; case 7: d += 182; break; case 8: d += 213; break; case 9: d += 244; break; case 10: d += 274; break; case 11: d += 305; break; case 12: d += 335; break; } switch (d % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Satday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
#include <math.h> #include <stdio.h> int p[10][10]; void drop(int x, int y) { if (-1 < x && x < 10 && -1 < y && y < 10) p[x][y]++; } int main(void) { int m, d; while (1) { scanf("%d %d", &m, &d); if (m == 0 && d == 0) break; switch (m) { case 2: d += 31; break; case 3: d += 60; break; case 4: d += 91; break; case 5: d += 121; break; case 6: d += 152; break; case 7: d += 182; break; case 8: d += 213; break; case 9: d += 244; break; case 10: d += 274; break; case 11: d += 305; break; case 12: d += 335; break; } switch (d % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
301
2
#include <stdio.h> int main() { int wdy; int mon, day, all = 0, i; char week[][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}, c; while (1) { scanf("%d%c%d", &mon, &c, &day); if (!mon) break; all = 0; for (i = 1; i < mon; i++) { switch (mon) { case 4: case 6: case 9: case 11: all += 30; break; case 2: all += 29; break; default: all += 31; break; } } wdy = (all + day) % 7; printf("%s\n", week + wdy); } return 0; }
#include <stdio.h> int main() { int wdy; int mon, day, all = 0, i; char week[][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}, c; while (1) { scanf("%d%c%d", &mon, &c, &day); if (!mon) break; all = 0; for (i = 1; i < mon; i++) { switch (i) { case 4: case 6: case 9: case 11: all += 30; break; case 2: all += 29; break; default: all += 31; break; } } wdy = (all + day) % 7; printf("%s\n", week + wdy); } return 0; }
[["-", 0, 7, 8, 9, 0, 99, 15, 23, 0, 22], ["+", 0, 7, 8, 9, 0, 99, 15, 23, 0, 22]]
0
176
2
char n[][7] = {"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"}; m; main(d) { for (; scanf("%d%d", &m, &d) * m; printf("%sday\n", n[(2497 + (m < 3 ? 0 : 2) + (m + 9) % 12 * 13 / 5 + d) % 7])) ; }
char n[][7] = {"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"}; m; main(d) { for (; scanf("%d%d", &m, &d) * m; printf("%sday\n", n[(3 + (m < 3 ? 0 : 2) + ((m + 9) % 12 * 13 + 47) / 5 + d) % 7])) ; }
[["-", 31, 23, 0, 16, 31, 16, 31, 16, 31, 13], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 16, 31, 16, 12, 16, 31, 23, 0, 24], ["+", 31, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 31, 16, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 16, 31, 16, 12, 16, 31, 23, 0, 25]]
0
106
18
#include <stdio.h> #define THIS_YEAR 2004 #define DAY_FIRST 2 // last year 12/31 is DAY_FIRST int main(void) { int month[12] = {31, // 1 28, // 2 31, // 3 30, // 4 31, // 5 30, // 6 31, // 7 31, // 8 30, // 9 31, // 10 30, // 11 31}; // 12 char theday[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int mon, day; int i; if ((THIS_YEAR % 4) == 0 || ((THIS_YEAR % 100) == 0 && THIS_YEAR % 400 == 0)) { month[1] = 29; } while (1) { scanf("%d %d", &mon, &day); if (mon == 0) break; for (i = 0; i < mon - 1; i++) { day += month[i]; } day = (day % 7) + DAY_FIRST; printf("%s\n", theday[day]); } return 0; }
#include <stdio.h> #define THIS_YEAR 2004 #define DAY_FIRST 2 // 0~6 (last year 12/31 is First day) int main(void) { int month[12] = {31, // 1 28, // 2 31, // 3 30, // 4 31, // 5 30, // 6 31, // 7 31, // 8 30, // 9 31, // 10 30, // 11 31}; // 12 char theday[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int mon, day; int i; if ((THIS_YEAR % 4) == 0 || ((THIS_YEAR % 100) == 0 && THIS_YEAR % 400 == 0)) { month[1] = 29; } while (1) { scanf("%d %d", &mon, &day); if (mon == 0) break; for (i = 0; i < mon - 1; i++) { day += month[i]; } day = (day + DAY_FIRST) % 7; printf("%s\n", theday[day]); } return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 109], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
0
218
8
#include <stdio.h> int main(void) { int MofY[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month, day; int past; char weeks[7][16] = {"Wednesday", "Thursday", "Friday", "Satuday", "Sunday", "Monday", "Tuesday"}; int w_num; int i, j; while (scanf("%d", &month), month) { scanf("%d", &day); past = 0; for (i = 0; i < month - 1; i++) { past += MofY[i]; } past += day; w_num = past % 7; printf("%s\n", weeks[w_num]); } return 0; }
#include <stdio.h> int main(void) { int MofY[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month, day; int past; char weeks[7][16] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int w_num; int i, j; while (scanf("%d", &month), month) { scanf("%d", &day); past = 0; for (i = 0; i < month - 1; i++) { past += MofY[i]; } past += day; w_num = past % 7; printf("%s\n", weeks[w_num]); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
0
176
2
#include <stdio.h> #include <stdlib.h> int main(void) { int month, day; int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char names[7][10] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; for (;;) { scanf("%d%d", &month, &day); if (month == day && !day) { break; } for (month--; month; month--) { day += days[month - 1]; } printf("%s\n", names[day % 7 - 1]); } return EXIT_SUCCESS; }
#include <stdio.h> #include <stdlib.h> int main(void) { int month, day; int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char names[7][10] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; for (;;) { scanf("%d%d", &month, &day); if (month == day && !day) { break; } for (month--; month; month--) { day += days[month - 1]; } printf("%s\n", names[(day - 1) % 7]); } return EXIT_SUCCESS; }
[["+", 3, 4, 0, 69, 71, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 69, 71, 16, 31, 16, 17, 109], ["-", 3, 4, 0, 69, 71, 16, 31, 16, 12, 13], ["+", 3, 4, 0, 69, 71, 16, 31, 23, 0, 25], ["+", 0, 2, 3, 4, 0, 69, 71, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 69, 71, 16, 12, 13]]
0
161
6
// // AOJ0027.c // // // Created by 中野 優 on 2014/02/22. // // #include <stdio.h> int main(void) { int i = 0, j, k, sum, n, month[100], date[100], md[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d %d", &month[i], &date[i]); if (month[i] == 0) break; i++; } for (j = 0; j < i; j++) { sum = 0; for (k = 0; k < month[j] - 1; k++) sum += md[k]; sum += date[j]; n = sum % 7; switch (n) { case 1: printf("Thuesday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; case 0: printf("Wednesday\n"); break; } } return 0; }
#include <stdio.h> int main(void) { int i = 0, j, k, sum, n, month[100], date[100], md[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { scanf("%d %d", &month[i], &date[i]); if (month[i] == 0) break; i++; } for (j = 0; j < i; j++) { sum = 0; for (k = 0; k < month[j] - 1; k++) sum += md[k]; sum += date[j]; n = sum % 7; switch (n) { case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; case 0: printf("Wednesday\n"); break; } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
266
2
#include <iostream> #include <string> using namespace std; int main() { string days[] = {"Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun"}; int cal[12][31] = {{0}}; int today = 3; for (int i = 0; i < 12; i++) { for (int j = 0; j < 31; j++) { cal[i][j] = today; ++today %= 7; if (i == 3 || i == 5 || i == 8 || i == 10) { if (j == 29) { break; } } else if (j == 1) { if (j == 28) { break; } } } } int a, b; for (cin >> a >> b; a; cin >> a >> b) { cout << days[cal[a - 1][b - 1]] << "day" << endl; } }
#include <iostream> #include <string> using namespace std; int main() { string days[] = {"Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun"}; int cal[12][31] = {{0}}; int today = 3; for (int i = 0; i < 12; i++) { for (int j = 0; j < 31; j++) { cal[i][j] = today; ++today %= 7; if (i == 3 || i == 5 || i == 8 || i == 10) { if (j == 29) { break; } } else if (i == 1) { if (j == 28) { break; } } } } int a, b; for (cin >> a >> b; a; cin >> a >> b) { cout << days[cal[a - 1][b - 1]] << "day" << endl; } }
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22]]
1
211
2
#include <iostream> #include <map> #include <string> using namespace std; string today(int month, int day) { string today; int startMonth = 1, startDay = 1, total = 0; for (int i = startMonth; i < month; i++) { switch (i) { case 4: case 6: case 9: case 11: total += 30; break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: total += 31; break; case 2: total += 29; break; } } total += day; // cout << total%7 << endl; switch (total % 7) { case 1: today = "Thursday"; break; case 2: today = "Friday"; break; case 3: today = "Saturday"; break; case 4: today = "Sunday"; break; case 5: today = "Mondday"; break; case 6: today = "Tusedday"; break; case 0: today = "Wednesday"; break; } return today; } int main(int argc, char const *argv[]) { int month, day, n; cin >> month >> day; while (month != 0 && day != 0) { cout << today(month, day) << endl; cin >> month >> day; } return 0; }
#include <iostream> #include <map> #include <string> using namespace std; string today(int month, int day) { string today; int startMonth = 1, startDay = 1, total = 0; for (int i = startMonth; i < month; i++) { switch (i) { case 4: case 6: case 9: case 11: total += 30; break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: total += 31; break; case 2: total += 29; break; } } total += day; // cout << total%7 << endl; switch (total % 7) { case 1: today = "Thursday"; break; case 2: today = "Friday"; break; case 3: today = "Saturday"; break; case 4: today = "Sunday"; break; case 5: today = "Monday"; break; case 6: today = "Tuesday"; break; case 0: today = "Wednesday"; break; } return today; } int main(int argc, char const *argv[]) { int month, day, n; cin >> month >> day; while (month != 0 && day != 0) { cout << today(month, day) << endl; cin >> month >> day; } return 0; }
[["-", 0, 100, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 0, 100, 0, 1, 0, 11, 12, 5, 0, 6]]
1
266
4
#include <algorithm> #include <array> #include <chrono> #include <fstream> #include <functional> #include <iostream> #include <map> #include <math.h> #include <memory.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) typedef long long Int; const double PI = 3.141592653589793238; const Int INF = 999999999999; typedef pair<int, int> P; int S[3][3] = { {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, }; int M[3][3] = { {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, }; int L[5][5] = { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }; string week[7]{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int dd[12]{3, 1, 3, 2, 3, 2, 3, 3, 2, 3, 3}; int main() { int m, d; while (cin >> m >> d, m && d) { int start = 3; int di(0); for (int i = 1; i < m; ++i) { di += dd[i - 1]; } di += (d - 1) % 7; di += start; di %= 7; cout << week[di] << endl; } return 0; }
#include <algorithm> #include <array> #include <chrono> #include <fstream> #include <functional> #include <iostream> #include <map> #include <math.h> #include <memory.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; #define REP(i, n) for (int i = 0; i < n; ++i) typedef long long Int; const double PI = 3.141592653589793238; const Int INF = 999999999999; typedef pair<int, int> P; int S[3][3] = { {0, 1, 0}, {1, 1, 1}, {0, 1, 0}, }; int M[3][3] = { {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, }; int L[5][5] = { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }; string week[7]{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int dd[11]{3, 1, 3, 2, 3, 2, 3, 3, 2, 3, 2}; int main() { int m, d; while (cin >> m >> d, m && d) { int start = 3; int di(0); for (int i = 1; i < m; ++i) { di += dd[i - 1]; } di += (d - 1) % 7; di += start; di %= 7; cout << week[di] << endl; } return 0; }
[["-", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
371
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char date[7][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int main() { int M, D, days = 0; while (1) { scanf("%d%d", &M, &D); if (M + D == 0) break; for (int i = 0; i < M - 1; i++) days += month[i]; printf("%s\n", date[(days + D) % 7]); } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char date[7][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int main() { int M, D, days = 0; while (1) { days = 0; scanf("%d%d", &M, &D); if (M + D == 0) break; for (int i = 0; i < M - 1; i++) days += month[i]; printf("%s\n", date[(days + D) % 7]); } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
182
4
#include <bits/stdc++.h> using namespace std; const int INF = 1e+9 * 2; double eps = 1e-10; string days[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; int main() { int m, d; while (cin >> m >> d && (m || d)) { int cnt = 0; for (int i = 1; i <= 12; ++i) { for (int j = 1; j <= 31; ++j) { if (m == i && j == d) { cout << days[cnt % 8] << endl; goto end; } cnt++; if (i == 2 && j == 29) break; else if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30) break; } } end:; } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 1e+9 * 2; double eps = 1e-10; string days[] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; int main() { int m, d; while (cin >> m >> d && (m || d)) { int cnt = 0; for (int i = 1; i <= 12; ++i) { for (int j = 1; j <= 31; ++j) { if (m == i && j == d) { cout << days[cnt % 7] << endl; goto end; } cnt++; if (i == 2 && j == 29) break; else if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30) break; } } end:; } return 0; }
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
192
2
#include <iostream> #include <string> using namespace std; int main() { string day[] = {"Wednesday", "Thirsday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int Mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int m, d; while (cin >> m >> d, m * d) { int allDay = d; for (int i = 1; i < m; i++) { allDay += Mon[i]; } cout << day[allDay % 7] << endl; } }
#include <iostream> #include <string> using namespace std; int main() { string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int Mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int m, d; while (cin >> m >> d, m * d) { int allDay = d; for (int i = 0; i < m - 1; i++) { allDay += Mon[i]; } cout << day[allDay % 7] << endl; } }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
139
6
#include <iostream> #include <cstdio> #include <cstdlib> #include <time.h> #include <math.h> #include <vector> #include <queue> #include <map> #include <set> #include <algorithm> #include <iterator> #include <sstream> #include <string> #include <bitset> using namespace std; #define FOR(I, F, N) for (int I = F; I < (int)(N); I++) #define rep(i, n) FOR(i, 0, n) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) typedef pair<int, int> P; typedef long long ll; typedef priority_queue<int> pq; int StrToInt(string); string IntToStr(int); int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int main(void) { int month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n, m; while (cin >> n >> m, n || m) { int day = 0; rep(i, n - 1) day += month[i]; day += m; int yo = day % 7; if (yo == 1) { FIN("Thursday"); } else if (yo == 2) { FIN("Friday"); } else if (yo == 3) { FIN("Saturday"); } else if (yo == 4) { FIN("Sunday"); } else if (yo == 5) { FIN("Monday"); } else if (yo == 6) { FIN("Tuesady"); } else if (yo == 0) { FIN("Wednesday"); } } return 0; } int StrToInt(string s) { stringstream ss; ss << s; int val; ss >> val; return val; } string IntToStr(int i) { stringstream ss; ss << i; return ss.str(); }
#include <iostream> #include <cstdio> #include <cstdlib> #include <time.h> #include <math.h> #include <vector> #include <queue> #include <map> #include <set> #include <algorithm> #include <iterator> #include <sstream> #include <string> #include <bitset> using namespace std; #define FOR(I, F, N) for (int I = F; I < (int)(N); I++) #define rep(i, n) FOR(i, 0, n) #define FIN(V) cout << V << endl #define pb push_back #define INF (1 << 30) typedef pair<int, int> P; typedef long long ll; typedef priority_queue<int> pq; int StrToInt(string); string IntToStr(int); int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int main(void) { int month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n, m; while (cin >> n >> m, n || m) { int day = 0; rep(i, n - 1) day += month[i]; day += m; int yo = day % 7; if (yo == 1) { FIN("Thursday"); } else if (yo == 2) { FIN("Friday"); } else if (yo == 3) { FIN("Saturday"); } else if (yo == 4) { FIN("Sunday"); } else if (yo == 5) { FIN("Monday"); } else if (yo == 6) { FIN("Tuesday"); } else if (yo == 0) { FIN("Wednesday"); } } return 0; } int StrToInt(string s) { stringstream ss; ss << s; int val; ss >> val; return val; } string IntToStr(int i) { stringstream ss; ss << i; return ss.str(); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
376
2
#include <iostream> #include <map> #include <vector> using namespace std; void getDays(int month, int day) { int dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int fst = 0; // 1/1 ?????? (month-1)??????????????\?????§?????\??° for (int i = 0; i < month - 1; i++) fst += dayNum[i]; fst++; // month???1??\?????§?????\??° switch (fst % 7) { case 0: cout << "Wednesday" << endl; break; case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; default: break; } } int main(void) { ios::sync_with_stdio(false); int month, day; while (1) { cin >> month >> day; if (month == 0) break; getDays(month, day); } return 0; }
#include <iostream> #include <map> #include <vector> using namespace std; void getDays(int month, int day) { int dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int fst = 0; // 1/1 ?????? (month-1)??????????????\?????§?????\??° for (int i = 0; i < month - 1; i++) fst += dayNum[i]; fst += day; // month???1??\?????§?????\??° switch (fst % 7) { case 0: cout << "Wednesday" << endl; break; case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; default: break; } } int main(void) { ios::sync_with_stdio(false); int month, day; while (1) { cin >> month >> day; if (month == 0) break; getDays(month, day); } return 0; }
[["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
238
3
#include <iostream> using namespace std; int main() { int m[13] = {0, 4, 7, 1, 4, 6, 7, 4, 7, 3, 5, 1, 3}; string a[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int M, D; while (cin >> M >> D && M && D) { int x = m[M] - 2; cout << a[(x + D) % 7] << endl; } }
#include <iostream> using namespace std; int main() { int m[13] = {0, 4, 7, 1, 4, 6, 2, 4, 7, 3, 5, 1, 3}; string a[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int M, D; while (cin >> M >> D && M && D) { int x = m[M] - 2; cout << a[(x + D) % 7] << endl; } }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
126
2
#include <iostream> using namespace std; int main() { int day30[5] = {3, 4, 6, 9, 11}; while (1) { int m, d; cin >> m >> d; if (m == 0 && d == 0) break; int a = 1, b = 1, count = 0; while (1) { if (a == m && b == d) break; b++; count++; if (a == 2 && b == 30) { a++; b = 1; } else if (b == 31) { for (int i = 0; i < 5; i++) if (day30[i] == a) { a++; b = 1; break; } } if (b == 32) { a++; b = 1; } } if (count % 7 == 4) cout << "Monday" << endl; else if (count % 7 == 5) cout << "Tuesday" << endl; else if (count % 7 == 6) cout << "Wednesday" << endl; else if (count % 7 == 0) cout << "Thursday" << endl; else if (count % 7 == 1) cout << "Friday" << endl; else if (count % 7 == 2) cout << "Saturday" << endl; else if (count % 7 == 3) cout << "Sunday" << endl; } return 0; }
#include <iostream> using namespace std; int main() { int day30[4] = {4, 6, 9, 11}; while (1) { int m, d; cin >> m >> d; if (m == 0 && d == 0) break; int a = 1, b = 1, count = 0; while (1) { if (a == m && b == d) break; b++; count++; if (a == 2 && b == 30) { a++; b = 1; } else if (b == 31) { for (int i = 0; i < 4; i++) if (day30[i] == a) { a++; b = 1; break; } } if (b == 32) { a++; b = 1; } } if (count % 7 == 4) cout << "Monday" << endl; else if (count % 7 == 5) cout << "Tuesday" << endl; else if (count % 7 == 6) cout << "Wednesday" << endl; else if (count % 7 == 0) cout << "Thursday" << endl; else if (count % 7 == 1) cout << "Friday" << endl; else if (count % 7 == 2) cout << "Saturday" << endl; else if (count % 7 == 3) cout << "Sunday" << endl; } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13]]
1
294
6
#include <iostream> using namespace std; int a[13][32]; void day(void) { int check = 3; for (int i = 1; i < 13; i++) { for (int j = 1; j < 32; j++) { a[i][j] = check; check++; if (check == 7) check = 0; if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30) break; else if (i == 2 && j == 29) break; } } } int main() { int mon, date; day(); while (1) { cin >> mon >> date; if (mon == 0 && date == 0) break; if (a[mon][date] == 0) cout << "Monday\n"; else if (a[mon][date] == 1) cout << "Tuesday\n"; else if (a[mon][date] == 2) cout << "Wednesday\n"; else if (a[mon][date] == 3) cout << "Thrusday\n"; else if (a[mon][date] == 4) cout << "Friday\n"; else if (a[mon][date] == 5) cout << "Saturday\n"; else cout << "Sunday\n"; } }
#include <iostream> using namespace std; int a[13][32]; void day(void) { int check = 3; for (int i = 1; i < 13; i++) { for (int j = 1; j < 32; j++) { a[i][j] = check; check++; if (check == 7) check = 0; if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30) break; else if (i == 2 && j == 29) break; } } } int main() { int mon, date; day(); while (1) { cin >> mon >> date; if (mon == 0 && date == 0) break; if (a[mon][date] == 0) cout << "Monday\n"; else if (a[mon][date] == 1) cout << "Tuesday\n"; else if (a[mon][date] == 2) cout << "Wednesday\n"; else if (a[mon][date] == 3) cout << "Thursday\n"; else if (a[mon][date] == 4) cout << "Friday\n"; else if (a[mon][date] == 5) cout << "Saturday\n"; else cout << "Sunday\n"; } }
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6]]
1
287
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) (r).begin(), (r).end() #define gsort(st, en) sort((st), (en), greater<int>()) #define rep(i, n) for (int i = 0; i < (n); ++i) #define repc(i, a, b) for (int i = (a); i < (b); ++i) #define repa(n, array) for (auto n : (array)) typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; constexpr int IMAX = ((1 << 30) - 1) * 2 + 1; constexpr int INF = 100000000; double EPS = 1e-10; const int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { cin.tie(0); ios::sync_with_stdio(false); int m, d, date = 3; while (1) { cin >> m >> d; if (m == 0) { break; } for (int i = 0; i < m - 1; ++i) { date += month[i] % 7; } date += d % 7 - 1; switch (date % 7) { case 0: cout << "Monday" << endl; break; case 1: cout << "Tuesday" << endl; break; case 2: cout << "Wednesday" << endl; break; case 3: cout << "Thursday" << endl; break; case 4: cout << "Friday" << endl; break; case 5: cout << "Saturday" << endl; break; case 6: cout << "Sunday" << endl; break; default: break; } } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) (r).begin(), (r).end() #define gsort(st, en) sort((st), (en), greater<int>()) #define rep(i, n) for (int i = 0; i < (n); ++i) #define repc(i, a, b) for (int i = (a); i < (b); ++i) #define repa(n, array) for (auto n : (array)) typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; constexpr int IMAX = ((1 << 30) - 1) * 2 + 1; constexpr int INF = 100000000; double EPS = 1e-10; const int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { cin.tie(0); ios::sync_with_stdio(false); int m, d, date = 3; while (1) { date = 3; cin >> m >> d; if (m == 0) { break; } for (int i = 0; i < m - 1; ++i) { date += month[i] % 7; } date += d % 7 - 1; switch (date % 7) { case 0: cout << "Monday" << endl; break; case 1: cout << "Tuesday" << endl; break; case 2: cout << "Wednesday" << endl; break; case 3: cout << "Thursday" << endl; break; case 4: cout << "Friday" << endl; break; case 5: cout << "Saturday" << endl; break; case 6: cout << "Sunday" << endl; break; default: break; } } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
341
4
#include <iostream> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; void print(int i) { if (i == 0) cout << "Monday" << endl; if (i == 1) cout << "Tuesday" << endl; if (i == 2) cout << "Wednesday" << endl; if (i == 3) cout << "Thursday" << endl; if (i == 4) cout << "Friday" << endl; if (i == 5) cout << "Saturday" << endl; if (i == 6) cout << "Sunday" << endl; return; } int main() { int m, d, num = 3; int season[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (cin >> m >> d, m) { rep(i, m - 1) num += season[i]; num += d - 1; num %= 7; print(num); } return 0; }
#include <iostream> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; void print(int i) { if (i == 0) cout << "Monday" << endl; if (i == 1) cout << "Tuesday" << endl; if (i == 2) cout << "Wednesday" << endl; if (i == 3) cout << "Thursday" << endl; if (i == 4) cout << "Friday" << endl; if (i == 5) cout << "Saturday" << endl; if (i == 6) cout << "Sunday" << endl; return; } int main() { int m, d, num = 3; int season[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (cin >> m >> d, m) { num = 3; rep(i, m - 1) num += season[i]; num += d - 1; num %= 7; print(num); } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
224
4
// 2004??´???366??\ /1/1 Thursday #include <cstdio> using namespace std; void today(int mon, int day); int main() { int mon, day; while (1) { scanf("%d %d", &mon, &day); if (mon == 0) { break; } today(mon, day); } return (0); } void today(int mon, int day) { int tmp = 0; for (int i = 1; i < mon; i++) { if (mon == 4 || mon == 6 || mon == 9 || mon == 11) { tmp += 30; } else if (mon == 2) { tmp += 29; } else { tmp += 31; } } switch ((tmp + day) % 7) { case 0: puts("Wednesday"); break; case 1: puts("Thursday"); break; case 2: puts("Friday"); break; case 3: puts("Saturday"); break; case 4: puts("Sunday"); break; case 5: puts("Monday"); break; case 6: puts("Tuesday"); break; } }
// 2004 366 1/1 Thursday #include <cstdio> using namespace std; void today(int mon, int day); int main() { int mon, day; while (1) { scanf("%d %d", &mon, &day); if (mon == 0) { break; } today(mon, day); } return (0); } void today(int mon, int day) { int tmp = 0; for (int i = 1; i < mon; i++) { if (i == 4 || i == 6 || i == 9 || i == 11) { tmp += 30; } else if (i == 2) { tmp += 29; } else { tmp += 31; } } switch ((tmp + day) % 7) { case 0: puts("Wednesday"); break; case 1: puts("Thursday"); break; case 2: puts("Friday"); break; case 3: puts("Saturday"); break; case 4: puts("Sunday"); break; case 5: puts("Monday"); break; case 6: puts("Tuesday"); break; } }
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 51, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 51, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 31, 22]]
1
241
10
#include <bits/stdc++.h> using namespace std; int main() { int data[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month, day; while (cin >> month >> day, month + day) { int sum = 0; for (int i = 0; i < month - 1; i++) { sum += data[i]; } sum += day; sum %= 7; if (sum == 1) { cout << "Thursday" << endl; } else if (sum == 2) { cout << "Friday" << endl; } else if (sum == 3) { cout << "Saturday" << endl; } else if (sum == 4) { cout << "Sunday" << endl; } else if (sum == 5) { cout << "Monday" << endl; } else if (sum == 6) { cout << "Thuesday" << endl; } else if (sum == 0) { cout << "Wednesday" << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int data[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month, day; while (cin >> month >> day, month + day) { int sum = 0; for (int i = 0; i < month - 1; i++) { sum += data[i]; } sum += day; sum %= 7; if (sum == 1) { cout << "Thursday" << endl; } else if (sum == 2) { cout << "Friday" << endl; } else if (sum == 3) { cout << "Saturday" << endl; } else if (sum == 4) { cout << "Sunday" << endl; } else if (sum == 5) { cout << "Monday" << endl; } else if (sum == 6) { cout << "Tuesday" << endl; } else if (sum == 0) { cout << "Wednesday" << endl; } } }
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
218
2
#include <iostream> #include <string> using namespace std; int x[13][32], y[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, sum, n, m; string T[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int main() { for (int i = 1; i <= 12; i++) { for (int j = 1; j <= y[i]; j++) { x[i][j] = sum % 7; sum++; } } while (true) { cin >> n >> m; if (!n) { break; } cout << T[x[n][m]] << endl; } }
#include <iostream> #include <string> using namespace std; int x[13][32], y[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, sum, n, m; string T[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int main() { sum = 4; for (int i = 1; i <= 12; i++) { for (int j = 1; j <= y[i]; j++) { x[i][j] = sum % 7; sum++; } } while (true) { cin >> n >> m; if (!n) { break; } cout << T[x[n][m]] << endl; } }
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
184
4
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define PRINT(STR) cout << STR << endl; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define REG(i, a, b) for (int(i) = ((int)(a)); (i) < ((int)(b)); i++) #define ALL(V) (V).begin(), (V).end() #define SPACE " " typedef long long ll; using namespace std; int nextInt() { int n = -1; cin >> n; return n; } double nextDouble() { double d = -1; cin >> d; return d; } ll nextll() { ll n = -1; cin >> n; return n; } string nextString() { string str; cin >> str; return str; } int INF = 1LL << 25; double EPS = 1e-9; // BEGIN ////////////////////////////////////////////////////////////// int main() { const int months[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const string answers[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (true) { int M = nextInt(); int D = nextInt(); if (M == 0) break; int past_days = 0; for (int i = 1; i < M; i++) { past_days += months[i]; } past_days += D; PRINT(answers[past_days % 7 - 1]); } return 0; } // END //////////////////////////////////////////////////////////////
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define PRINT(STR) cout << STR << endl; #define REP(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define REG(i, a, b) for (int(i) = ((int)(a)); (i) < ((int)(b)); i++) #define ALL(V) (V).begin(), (V).end() #define SPACE " " typedef long long ll; using namespace std; int nextInt() { int n = -1; cin >> n; return n; } double nextDouble() { double d = -1; cin >> d; return d; } ll nextll() { ll n = -1; cin >> n; return n; } string nextString() { string str; cin >> str; return str; } int INF = 1LL << 25; double EPS = 1e-9; // BEGIN ////////////////////////////////////////////////////////////// int main() { const int months[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const string answers[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (true) { int M = nextInt(); int D = nextInt(); if (M == 0) break; int past_days = -1; for (int i = 1; i < M; i++) { past_days += months[i]; } past_days += D; PRINT(answers[past_days % 7]); } return 0; } // END //////////////////////////////////////////////////////////////
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
309
4
#define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; string a[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int b[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { for (int m, d; cin >> m >> d && m;) { while (m) d += b[--m]; cout << a[d % 7 - 1 + 3] << endl; } return 0; }
#define _USE_MATH_DEFINES #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; string a[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int b[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { for (int m, d; cin >> m >> d && m;) { while (m) d += b[--m]; cout << a[(d - 1 + 3) % 7] << endl; } return 0; }
[["+", 12, 69, 341, 342, 0, 16, 31, 23, 0, 24], ["-", 341, 342, 0, 16, 31, 16, 31, 16, 17, 109], ["-", 341, 342, 0, 16, 31, 16, 31, 16, 12, 13], ["+", 12, 69, 341, 342, 0, 16, 31, 23, 0, 25], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 109], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
158
6
#include <iostream> #include <string> using namespace std; int main() { string y[7] = {"Wednesday", "Thrsday", "Frinday", "Saturday", "Sunday", "Monday", "Tuesday"}; int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { int m, d; cin >> m >> d; if (m == 0 && d == 0) break; while (m != 0) { d += mon[m - 1]; m--; } cout << y[d % 7] << endl; } }
#include <iostream> #include <string> using namespace std; int main() { string y[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { int m, d; cin >> m >> d; if (m == 0 && d == 0) break; while (m != 0) { d += mon[m - 1]; m--; } cout << y[d % 7] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
144
7
#include <iostream> #include <string> using namespace std; string days[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int daysPerMonth[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; int main() { int m, d; while (cin >> m >> d) { int day = 0; for (int i = 0; i < m - 1; i++) { day += daysPerMonth[i]; } day += d; cout << days[day % 7] << endl; } return 0; }
#include <iostream> #include <string> using namespace std; string days[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int daysPerMonth[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; int main() { int m, d; while (cin >> m >> d, m + d) { int day = 0; for (int i = 0; i < m - 1; i++) { day += daysPerMonth[i]; } day += d; cout << days[day % 7] << endl; } return 0; }
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 72], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
1
143
4
#include <iostream> using namespace std; int main(void) { int Month[13]{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //??????0?????\???6 int dow = 2; int in_day, in_month; while (cin >> in_month >> in_day) { if (in_month == 0) break; dow = 2; for (int i = 0; i < in_month; i++) { dow += Month[i]; } dow += in_day; if (dow % 7 == 0) { cout << "Monthday" << endl; } else if (dow % 7 == 1) { cout << "Tuesday" << endl; } else if (dow % 7 == 2) { cout << "Wednesday" << endl; } else if (dow % 7 == 3) { cout << "Thursday" << endl; } else if (dow % 7 == 4) { cout << "Friday" << endl; } else if (dow % 7 == 5) { cout << "Saturday" << endl; } else if (dow % 7 == 6) { cout << "Sunday" << endl; } } return 0; }
#include <iostream> #include <vector> using namespace std; int main(void) { /* double x[3] = { 0,0,0 }; double y[3] = { 0,0,0 }; double xp = 0, yp = 0; int flag[3] = { 0,0,0 }; while (cin >> x[0]>> y[0]>> x[1]>> y[1]>> x[2]>> y[2]>> xp>> yp) { for (int i = 0; i < 3; i++) { int temp1 = (i + 1) % 3; int temp2 = (i + 2) % 3; double checkI = (y[temp1] - y[i]) * (x[temp2] - x[i]) - (x[temp1] - x[i]) * (y[temp2] - y[i]); double checkP = (y[temp1] - y[i]) * (xp - x[i]) - (x[temp1] - x[i]) * (yp - y[i]); if (checkI * checkP > 0) { flag[i] = 1; } } if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } flag[0] = 0; flag[1] = 0; flag[2] = 0; } */ /* int input_num; vector<int> train_num; while (cin >> input_num) { if (input_num == 0) { cout << train_num.back() << endl; train_num.pop_back(); } else if (input_num >= 1 && input_num <= 10) { train_num.push_back(input_num); } } */ /* int d; int sum = 0; while (cin >> d) { for (int i = 0; i < 600 / d; i++) { sum += d*i*d*i*d; } cout << sum << endl; sum = 0; } */ /* int a[4], b[4]; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { int hit = 0; int blow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { hit++; } else { blow++; } } } } cout << hit << " " << blow << endl; } */ int Month[13]{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //??????0?????\???6 int dow = 2; int in_day, in_month; while (cin >> in_month >> in_day) { if (in_month == 0) break; dow = 2; for (int i = 0; i < in_month; i++) { dow += Month[i]; } dow += in_day; if (dow % 7 == 0) { cout << "Monday" << endl; } else if (dow % 7 == 1) { cout << "Tuesday" << endl; } else if (dow % 7 == 2) { cout << "Wednesday" << endl; } else if (dow % 7 == 3) { cout << "Thursday" << endl; } else if (dow % 7 == 4) { cout << "Friday" << endl; } else if (dow % 7 == 5) { cout << "Saturday" << endl; } else if (dow % 7 == 6) { cout << "Sunday" << endl; } } return 0; }
[["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
241
4
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <string> #include <vector> #define shosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typedef pair<int, P> pip; typedef vector<pip> vip; const int inf = 1 << 30; const double pi = acos(-1); int x, y, tu[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; int main() { while (1) { cin >> x >> y; if (!x && !y) break; int num = 0; for (int i = 0; i < x - 1; i++) num += tu[i]; num += y; int ans = num % 7; if (ans == 1) cout << "Thursday" << endl; else if (ans == 2) cout << "Friday" << endl; else if (ans == 3) cout << "Saturday" << endl; else if (ans == 4) cout << "Sunday" << endl; else if (ans == 5) cout << "Monday" << endl; else if (ans == 6) cout << "Tuesday" << endl; else if (!ans) cout << "Wednsday" << endl; } }
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <string> #include <vector> #define shosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typedef pair<int, P> pip; typedef vector<pip> vip; const int inf = 1 << 30; const double pi = acos(-1); int x, y, tu[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; int main() { while (1) { cin >> x >> y; if (!x && !y) break; int num = 0; for (int i = 0; i < x - 1; i++) num += tu[i]; num += y; int ans = num % 7; if (ans == 1) cout << "Thursday" << endl; else if (ans == 2) cout << "Friday" << endl; else if (ans == 3) cout << "Saturday" << endl; else if (ans == 4) cout << "Sunday" << endl; else if (ans == 5) cout << "Monday" << endl; else if (ans == 6) cout << "Tuesday" << endl; else if (!ans) cout << "Wednesday" << endl; } }
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
305
2
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = a; i >= n; i--) #define pb(a) push_back(a) #define fr first #define sc second #define INF 999999999 #define X real() #define Y imag() #define EPS (1e-10) #define EQ(a, b) (abs((a) - (b)) < EPS) #define EQV(a, b) (EQ((a).X, (b).X) && EQ((a).Y, (b).Y)) #define LE(n, m) ((n) < (m) + EPS) #define GE(n, m) ((n) + EPS > (m)) typedef vector<int> VI; typedef vector<VI> MAT; typedef pair<int, int> pii; typedef long long int ll; typedef complex<double> P; typedef pair<P, P> L; typedef pair<P, double> C; int const MOD = 1000000007; int dayOfTheWeek(int y, int m, int d) { if (m < 3) { y--; m += 12; } return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7; } int main() { string dayname[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int m, d; while (cin >> m, m) { cin >> d; cout << dayname[dayOfTheWeek(2016, m, d)] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = a; i >= n; i--) #define pb(a) push_back(a) #define fr first #define sc second #define INF 999999999 #define X real() #define Y imag() #define EPS (1e-10) #define EQ(a, b) (abs((a) - (b)) < EPS) #define EQV(a, b) (EQ((a).X, (b).X) && EQ((a).Y, (b).Y)) #define LE(n, m) ((n) < (m) + EPS) #define GE(n, m) ((n) + EPS > (m)) typedef vector<int> VI; typedef vector<VI> MAT; typedef pair<int, int> pii; typedef long long int ll; typedef complex<double> P; typedef pair<P, P> L; typedef pair<P, double> C; int const MOD = 1000000007; int dayOfTheWeek(int y, int m, int d) { if (m < 3) { y--; m += 12; } return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7; } int main() { string dayname[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int m, d; while (cin >> m, m) { cin >> d; cout << dayname[dayOfTheWeek(2004, m, d)] << endl; } return 0; }
[["-", 12, 69, 341, 342, 0, 2, 3, 4, 0, 13], ["+", 12, 69, 341, 342, 0, 2, 3, 4, 0, 13]]
1
281
2
#include <iostream> using namespace std; int main() { int m, d, ans, month, i, total = 0; while (1) { cin >> m >> d; if (m == 0) break; for (i = 1; i < m; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { total += 31; } else if (i == 2) { total += 29; } else { total += 30; } } total += d; ans = total % 7; switch (ans) { case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuseday" << endl; break; case 0: cout << "Wednesday" << endl; break; } ans = 0, total = 0; } return 0; }
#include <iostream> using namespace std; int main() { int m, d, ans, month, i, total = 0; while (1) { cin >> m >> d; if (m == 0) break; for (i = 1; i < m; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) { total += 31; } else if (i == 2) { total += 29; } else { total += 30; } } total += d; ans = total % 7; switch (ans) { case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; case 0: cout << "Wednesday" << endl; break; } ans = 0, total = 0; } return 0; }
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
236
2
#include <iostream> #include <map> #include <string> #include <utility> using namespace std; map<pair<int, int>, string> mp; string s[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int main() { int cnt = 3; for (int i = 1; i <= 12; i++) { int days; if (i == 2) days = 29; if (i & 1) days = (i <= 7 ? 31 : 30); else days = (i <= 7 ? 30 : 31); for (int j = 1; j <= days; j++) { mp[make_pair(i, j)] = s[cnt++]; cnt %= 7; } } int m, d; while (true) { cin >> m >> d; if (m == 0) return 0; cout << mp[make_pair(m, d)] << endl; } return 0; }
#include <iostream> #include <map> #include <string> #include <utility> using namespace std; map<pair<int, int>, string> mp; string s[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int main() { int cnt = 3; for (int i = 1; i <= 12; i++) { int days; if (i == 2) days = 29; else if (i & 1) days = (i <= 7 ? 31 : 30); else days = (i <= 7 ? 30 : 31); for (int j = 1; j <= days; j++) { mp[make_pair(i, j)] = s[cnt++]; cnt %= 7; } } int m, d; while (true) { cin >> m >> d; if (m == 0) return 0; cout << mp[make_pair(m, d)] << endl; } return 0; }
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
211
1
#include <cstdio> using namespace std; bool testcase_ends() { int m, d; scanf("%d %d", &m, &d); if (m == 0 && d == 0) return 1; int offset[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; const char *day[] = {"Mon", "Tues", "Wednes", "Thurs", "Fri", "Sat", "Sun"}; printf("%sday\n", day[(offset[m - 1] + d + 2) % 7]); return 0; } int main() { int solved = 0; while (!testcase_ends()) ++solved; return !solved; }
#include <cstdio> using namespace std; bool testcase_ends() { int m, d; scanf("%d %d", &m, &d); if (m == 0 && d == 0) return 1; int offset[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; const char *day[] = {"Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun"}; printf("%sday\n", day[(offset[m - 1] + d + 2) % 7]); return 0; } int main() { int solved = 0; while (!testcase_ends()) ++solved; return !solved; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
165
2
#include <algorithm> #include <bits/stdc++.h> #include <list> #include <map> #include <queue> #include <stack> #include <vector> using namespace std; int main() { int mod = 1000000007; int m, d; int p[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<int, string> week; week[0] = "Monday"; week[1] = "Tuesday"; week[2] = "Wednesday"; week[3] = "Thursday"; week[4] = "Friday"; week[5] = "Suturday"; week[6] = "Sunday"; for (;;) { scanf("%d %d", &m, &d); if (d == 0) break; int tmp = 3; if (m > 1) { for (int i = 1; i < m; i++) { tmp = (tmp + p[i]) % 7; } } cout << week[(tmp + d - 1) % 7] << endl; } return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <list> #include <map> #include <queue> #include <stack> #include <vector> using namespace std; int main() { int mod = 1000000007; int m, d; int p[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<int, string> week; week[0] = "Monday"; week[1] = "Tuesday"; week[2] = "Wednesday"; week[3] = "Thursday"; week[4] = "Friday"; week[5] = "Saturday"; week[6] = "Sunday"; for (;;) { scanf("%d %d", &m, &d); if (m == 0) break; int tmp = 3; if (m > 1) { for (int i = 1; i < m; i++) { tmp = (tmp + p[i]) % 7; } } cout << week[(tmp + d - 1) % 7] << endl; } return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
229
4
#include <algorithm> #include <iostream> #include <stack> #include <stdio.h> using namespace std; int main(void) { int month, day, ans; while (1) { cin >> month >> day; if (month == 0) break; if (month == 1) { ans = day; } if (month == 2) { ans = day + 31; } if (month == 3) { ans = day + 60; } if (month == 4) { ans = day + 91; } if (month == 5) { ans = day + 121; } if (month == 6) { ans = day + 152; } if (month == 7) { ans = day + 182; } if (month == 8) { ans = day + 213; } if (month == 9) { ans = day + 244; } if (month == 10) { ans = day + 274; } if (month == 11) { ans = day + 305; } if (month == 12) { ans = day + 366; } ans = ans % 7; if (ans == 1) cout << "Thursday" << endl; if (ans == 2) cout << "Frisday" << endl; if (ans == 3) cout << "Saturday" << endl; if (ans == 4) cout << "Sunday" << endl; if (ans == 5) cout << "Monday" << endl; if (ans == 6) cout << "Tuesday" << endl; if (ans == 0) cout << "Wednesday" << endl; } return 0; }
#include <algorithm> #include <iostream> #include <stack> #include <stdio.h> using namespace std; int main(void) { int month, day, ans; while (1) { cin >> month >> day; if (month == 0) break; if (month == 1) { ans = day; } if (month == 2) { ans = day + 31; } if (month == 3) { ans = day + 60; } if (month == 4) { ans = day + 91; } if (month == 5) { ans = day + 121; } if (month == 6) { ans = day + 152; } if (month == 7) { ans = day + 182; } if (month == 8) { ans = day + 213; } if (month == 9) { ans = day + 244; } if (month == 10) { ans = day + 274; } if (month == 11) { ans = day + 305; } if (month == 12) { ans = day + 335; } ans = ans % 7; if (ans == 1) cout << "Thursday" << endl; if (ans == 2) cout << "Friday" << endl; if (ans == 3) cout << "Saturday" << endl; if (ans == 4) cout << "Sunday" << endl; if (ans == 5) cout << "Monday" << endl; if (ans == 6) cout << "Tuesday" << endl; if (ans == 0) cout << "Wednesday" << endl; } return 0; }
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
319
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; int main() { int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Thuesday"}; int m, d; while (cin >> m >> d) { if (m == 0 || d == 0) break; int tmp = d; for (int i = 0; i < m; i++) tmp += M[i]; cout << w[tmp % 7] << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; int main() { int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int m, d; while (cin >> m >> d) { if (m == 0 || d == 0) break; int tmp = d; for (int i = 0; i < m; i++) tmp += M[i]; cout << w[tmp % 7] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
165
2
#include <stdio.h> int main() { int month, day, n; int md[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 31, 30}; while (1) { scanf("%d %d", &month, &day); if (month == 0) break; n = 0; for (int i = 0; i < month; i++) { n += md[i]; } n += day; switch (n % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
#include <stdio.h> int main() { int month, day, n; int md[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30}; while (1) { scanf("%d %d", &month, &day); if (month == 0) break; n = 0; for (int i = 0; i < month; i++) { n += md[i]; } n += day; switch (n % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21]]
1
205
2
#include <iostream> #include <string> using namespace std; int main() { string week[7] = {"Mondey", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int m, d, cnt, mc; while (cin >> m >> d) { if (m == 0) break; mc = 1; cnt = 3; while (1) { for (int i = 1; i <= month[mc - 1]; i++, cnt++) { if (m == mc && d == i) break; } if (m == mc) break; mc++; } cout << week[cnt % 7] << endl; } return 0; }
#include <iostream> #include <string> using namespace std; int main() { string week[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int m, d, cnt, mc; while (cin >> m >> d) { if (m == 0) break; mc = 1; cnt = 3; while (1) { for (int i = 1; i <= month[mc - 1]; i++, cnt++) { if (m == mc && d == i) break; } if (m == mc) break; mc++; } cout << week[cnt % 7] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
184
2
#include <bits/stdc++.h> using namespace std; int main(void) { while (1) { int month, day; int days_from_new_year = 0; cin >> month >> day; if (month == 0 && day == 0) break; for (int i = 1; i < month; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) days_from_new_year += 31; else if (i == 4 || i == 6 || i == 9 || i == 12) days_from_new_year += 30; else if (i == 2) days_from_new_year += 29; } days_from_new_year += day; int mod = days_from_new_year % 7; if (mod == 0) cout << "Wednesday"; else if (mod == 1) cout << "Thursday"; else if (mod == 2) cout << "Friday"; else if (mod == 3) cout << "Saturday"; else if (mod == 4) cout << "Sunday"; else if (mod == 5) cout << "Monday"; else if (mod == 6) cout << "Tuesday"; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { while (1) { int month, day; int days_from_new_year = 0; cin >> month >> day; if (month == 0 && day == 0) break; for (int i = 1; i < month; i++) { if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) days_from_new_year += 31; else if (i == 4 || i == 6 || i == 9 || i == 11) days_from_new_year += 30; else if (i == 2) days_from_new_year += 29; } days_from_new_year += day; int mod = days_from_new_year % 7; if (mod == 0) cout << "Wednesday"; else if (mod == 1) cout << "Thursday"; else if (mod == 2) cout << "Friday"; else if (mod == 3) cout << "Saturday"; else if (mod == 4) cout << "Sunday"; else if (mod == 5) cout << "Monday"; else if (mod == 6) cout << "Tuesday"; cout << endl; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
239
2
#include <iostream> #include <string> #include <vector> int main() { std::vector<std::string> day_of_week{"Thursday", "Friday", "Suterday", "Sunday", "Monday", "Tuesday", "Wednesday"}; std::vector<int> day_num_of_month{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month = 0; int day = 0; while (std::cin >> month >> day) { if (0 == month) { break; } int days_elapsed = 0; for (int m = 1; m < month; ++m) { days_elapsed += day_num_of_month[m - 1]; } days_elapsed += day; std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl; } return 0; }
#include <iostream> #include <string> #include <vector> int main() { std::vector<std::string> day_of_week{"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; std::vector<int> day_num_of_month{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month = 0; int day = 0; while (std::cin >> month >> day) { if (0 == month) { break; } int days_elapsed = 0; for (int m = 1; m < month; ++m) { days_elapsed += day_num_of_month[m - 1]; } days_elapsed += day; std::cout << day_of_week[(days_elapsed - 1) % 7] << std::endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
172
2
// clang-format off #include <bits/stdc++.h> #define int long long #define main signed main() // #define main int main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n) #define stlice(from, to) substr(from, (to) - (from) + 1) #define pb push_back #define mp make_pair #define mt make_tuple #define fi first #define se second using namespace std; using pii = pair<int, int>; using vi = vector<int>; using vd = vector<double>; using vc = vector<char>; using vb = vector<bool>; using vs = vector<string>; using vpii = vector<pii>; using vvi = vector<vi>; using vvb = vector<vb>; using vvpii = vector<vpii>; template<typename A> using fn = function<A>; constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000; constexpr int MOD = 1000000007; constexpr double PI = acos(-1); template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } constexpr bool odd(const int &n) { return n & 1; } constexpr bool even(const int &n) { return !odd(n); } template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); } void solve(); main { solve(); return 0; } // clang-format on constexpr int zeller(int y, int m, const int &d) { if (m == 1 || m == 2) y--, m += 12; int k = y % 100, j = y / 100; return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; } void solve() { int m, d; string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; while (cin >> m >> d, m) cout << t[zeller(2014, m, d)] << endl; }
// clang-format off #include <bits/stdc++.h> #define int long long #define main signed main() // #define main int main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecision(n) #define stlice(from, to) substr(from, (to) - (from) + 1) #define pb push_back #define mp make_pair #define mt make_tuple #define fi first #define se second using namespace std; using pii = pair<int, int>; using vi = vector<int>; using vd = vector<double>; using vc = vector<char>; using vb = vector<bool>; using vs = vector<string>; using vpii = vector<pii>; using vvi = vector<vi>; using vvb = vector<vb>; using vvpii = vector<vpii>; template<typename A> using fn = function<A>; constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000; constexpr int MOD = 1000000007; constexpr double PI = acos(-1); template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } constexpr bool odd(const int &n) { return n & 1; } constexpr bool even(const int &n) { return !odd(n); } template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); } void solve(); main { solve(); return 0; } // clang-format on constexpr int zeller(int y, int m, const int &d) { if (m == 1 || m == 2) y--, m += 12; int k = y % 100, j = y / 100; return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j + 6) % 7; } void solve() { int m, d; string t[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; while (cin >> m >> d, m) cout << t[zeller(2004, m, d)] << endl; }
[["+", 0, 37, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 37, 0, 16, 31, 23, 0, 16, 12, 13], ["-", 12, 69, 341, 342, 0, 2, 3, 4, 0, 13], ["+", 12, 69, 341, 342, 0, 2, 3, 4, 0, 13]]
1
507
4
#include <iostream> #include <string> using namespace std; int main() { const int n_day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const string week_name[] = {"Wednesday", "Thursday", "Firday", "Saturday", "Sunday", "Monday", "Tuesday"}; int m, d, sum = 0; cin >> m >> d; while (m != 0 && d != 0) { m--; for (int i = 0; i < m; i++) { sum += n_day[i]; } sum += d; cout << week_name[sum % 7] << endl; sum = 0; cin >> m >> d; } return 0; }
#include <iostream> #include <string> using namespace std; int main() { const int n_day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const string week_name[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int m, d, sum = 0; cin >> m >> d; while (m != 0 && d != 0) { m--; for (int i = 0; i < m; i++) { sum += n_day[i]; } sum += d; cout << week_name[sum % 7] << endl; sum = 0; cin >> m >> d; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
163
2
#include "bits/stdc++.h" using namespace std; int main() { int m, d; int mm[] = {31, 29, 31, 30, 31, 30, 31, 31, 31, 31, 30, 31}; string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (cin >> m >> d) { if (m == 0) break; int dd = 0; for (int i = 0; i < m - 1; i++) dd += mm[i]; dd += d; int ans = (dd + 2) % 7; // cout<<dd<<endl; cout << s[ans] << endl; } return 0; }
#include "bits/stdc++.h" using namespace std; int main() { int m, d; int mm[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (cin >> m >> d) { if (m == 0) break; int dd = 0; for (int i = 0; i < m - 1; i++) dd += mm[i]; dd += d; int ans = (dd + 2) % 7; // cout<<dd<<endl; cout << s[ans] << endl; } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
159
2
#include <cstdio> #include <iostream> using namespace std; int main() { int a[4]; int b[4]; int brow, hit; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hit = brow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[i]) { brow++; break; } } } for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; } } cout << hit << " " << brow << endl; } return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int a[4]; int b[4]; int brow, hit; while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) { hit = brow = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { brow++; break; } } } for (int i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; } } cout << hit << " " << brow - hit << endl; } return 0; }
[["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
182
4
#include <stdio.h> int main(void) { int a[4]; int b[4]; int i, j; int hit, blow; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); hit = 0; blow = 0; for (i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; } } for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) { blow++; } } } blow = blow - hit; printf("%d %d", hit, blow); } return 0; }
#include <stdio.h> int main(void) { int a[4]; int b[4]; int i, j; int hit, blow; while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF) { scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]); hit = 0; blow = 0; for (i = 0; i < 4; i++) { if (a[i] == b[i]) { hit++; } } for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (a[i] == b[j]) { blow++; } } } blow = blow - hit; printf("%d %d\n", hit, blow); } return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
206
1
#include <iostream> using namespace std; int main() { int a[4], b[4]; while (1) { for (int i = 0; i < 4; ++i) cin >> a[i]; for (int i = 0; i < 4; ++i) cin >> b[i]; if (cin.eof()) break; int hit = 0, blow = 0; for (int i = 0; i < 4; ++i) { for (int j = i; j < 4; ++j) { if (a[i] == b[j] && i == j) { hit++; } else if (a[i] == b[j]) { blow++; } } } cout << hit << " " << blow << endl; } }
#include <iostream> using namespace std; int main() { int a[4], b[4]; while (1) { for (int i = 0; i < 4; ++i) cin >> a[i]; for (int i = 0; i < 4; ++i) cin >> b[i]; if (cin.eof()) break; int hit = 0, blow = 0; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (a[i] == b[j] && i == j) { hit++; } else if (a[i] == b[j]) { blow++; } } } cout << hit << " " << blow << endl; } }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
173
2
#include <iostream> using namespace std; int main() { int a[4], b[4], count, count_2; while (cin >> a[0] >> a[1] >> a[2] >> a[4]) { cin >> b[0] >> b[1] >> b[2] >> b[3]; count = 0; count_2 = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { count++; } else { count_2++; } } } } cout << count << " " << count_2 << endl; } return 0; }
#include <iostream> using namespace std; int main() { int a[4], b[4], count, count_2; while (cin >> a[0] >> a[1] >> a[2] >> a[3]) { cin >> b[0] >> b[1] >> b[2] >> b[3]; count = 0; count_2 = 0; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i] == b[j]) { if (i == j) { count++; } else { count_2++; } } } } cout << count << " " << count_2 << endl; } return 0; }
[["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 13]]
1
161
2
#!ruby -pal b=gets.split $_="#{c=$_.zip(b).count{|x,y|x==y}} #{($_&b).size-c}"
#!ruby -pal b=gets.split $_="#{c=$F.zip(b).count{|x,y|x==y}} #{($F&b).size-c}"
[["-", 0, 284, 0, 662, 12, 652, 486, 652, 486, 744], ["+", 0, 284, 0, 662, 12, 652, 486, 652, 486, 744], ["-", 0, 738, 31, 652, 486, 739, 0, 652, 735, 744], ["+", 0, 738, 31, 652, 486, 739, 0, 652, 735, 744]]
4
44
4
while gets a=$<.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times do |i| if a[i]==b[i] then c+=1 else 4.times do |j| if a[i]==b[j] then d+=1;break; end end end end print c," ",d,"\n" end
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times do |i| if a[i]==b[i] then c+=1 else 4.times do |j| if a[i]==b[j] then d+=1;break; end end end end print c," ",d,"\n" end
[["-", 8, 170, 0, 662, 12, 652, 486, 652, 486, 744], ["+", 8, 170, 0, 662, 12, 652, 486, 652, 486, 744]]
4
95
2
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } p "#{c} #{d}" end
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } puts "#{c} #{d}" end
[["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["+", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22]]
4
92
7
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } p "#{c} #{d}" end
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c=d=0 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } puts "#{c} #{d}" end
[["-", 0, 89, 8, 170, 0, 662, 31, 761, 0, 21], ["+", 0, 493, 0, 89, 8, 170, 0, 662, 0, 32], ["-", 0, 89, 8, 170, 0, 662, 12, 762, 0, 21], ["-", 0, 89, 8, 170, 0, 662, 12, 762, 0, 612], ["-", 36, 36, 0, 493, 0, 89, 8, 170, 0, 35], ["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["+", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22]]
4
92
7
#!/usr/bin/ruby until (a = gets).nil? a = a.split; b = gets.split hit = a.map.with_index{|e,i| e == b[i-1]}.count(true) blow = (a & b).size - hit puts "#{hit} #{blow}" end
#!/usr/bin/ruby until (a = gets).nil? a = a.split; b = gets.split hit = a.map.with_index{|e,i| e == b[i]}.count(true) blow = (a & b).size - hit puts "#{hit} #{blow}" end
[["-", 8, 734, 0, 738, 12, 742, 0, 738, 17, 33], ["-", 8, 734, 0, 738, 12, 742, 0, 738, 12, 612]]
4
69
2
input = gets(nil) a = [] b = [] input.split("\n").each_with_index do |line, i| if i % 2 == 0 a = line.split(" ").map(&:to_i) next end b = line.split(" ").map(&:to_i) s1 = 0 s2 = 0 0.upto(3) do |i| s1 += 1 if a[i] == b[i] s2 += 1 if a.include?(b[i]) end puts "#{s1} #{s2}" end
input = gets(nil) a = [] b = [] input.split("\n").each_with_index do |line, i| if i % 2 == 0 a = line.split(" ").map(&:to_i) next end b = line.split(" ").map(&:to_i) s1 = 0 s2 = 0 0.upto(3) do |i| s1 += 1 if a[i] == b[i] s2 += 1 if a.include?(b[i]) end puts "#{s1} #{s2-s1}" end
[["+", 3, 4, 0, 557, 0, 284, 0, 738, 17, 33], ["+", 3, 4, 0, 557, 0, 284, 0, 738, 12, 22]]
4
124
2
# -*- coding: utf-8 -*- while True: try: A, B = input().split(), input().split() hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ]) blow = sum([ 1 for i in range(len(A)) if B[i] in A ]) print(str(hit) + ' ' +str(blow)) except: break
# -*- coding: utf-8 -*- while True: try: A, B = input().split(), input().split() hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ]) blow = sum([ 1 for i in range(len(A)) if B[i] in A ]) - hit print(str(hit) + ' ' +str(blow)) except: break
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
97
2
import sys def hitBlow(a, b): hit = 0 blow = 0 for i in range(len(a)): if a[i] == b[i]: hit += 1 for j in range(i+1, len(b)): if a[i] == b[j]: blow += 1 return [hit, blow] for s in sys.stdin: a = list(map(int, s.split())) b = list(map(int, input().split())) hit, blow = hitBlow(a, b) print(hit, blow)
import sys def hitBlow(a, b): hit = 0 blow = 0 for i in range(len(a)): if a[i] == b[i]: hit += 1 else: for j in range(len(b)): if a[i] == b[j]: blow += 1 return [hit, blow] for s in sys.stdin: a = list(map(int, s.split())) b = list(map(int, input().split())) hit, blow = hitBlow(a, b) print(hit, blow)
[["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
131
6
# -*- coding:utf-8 -*- def main(): while True: try: A=input().split() B=input().split() Hit=0 Blow=0 for b in B: if b in A: index=B.index(b) print(index) if b==A[index]: Hit+=1 else: Blow+=1 print(Hit,Blow) except: break if __name__ == '__main__': main()
# -*- coding:utf-8 -*- def main(): while True: try: A=input().split() B=input().split() Hit=0 Blow=0 for b in B: if b in A: index=B.index(b) if b==A[index]: Hit+=1 else: Blow+=1 print(Hit,Blow) except: break if __name__ == '__main__': main()
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
92
4
while True: try: ansa=hoge1.split() ansb=hoge2.split() except: break hit = sum((1 for a, b in zip(ansa, ansb) if a == b)) blow = sum((1 for a in ansa if a in ansb)) print(hit, blow - hit)
while True: try: ansa=input().split() ansb=input().split() except: break hit = sum((1 for a, b in zip(ansa, ansb) if a == b)) blow = sum((1 for a in ansa if a in ansb)) print(hit, blow - hit)
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 662, 12, 652, 63, 319, 500, 652, 63, 22], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25]]
5
69
8
import sys even = True for s in sys.stdin: if even: even = not even a = list(map(int, s.split())) else: b = list(map(int, s.split())) hit = sum(a[i] == b[i] for i in range(4)) blow = sum(b[i] in a for i in range(4)) - hit print(hit, blow)
import sys even = True for s in sys.stdin: if even: even = False a = list(map(int, s.split())) else: even = True b = list(map(int, s.split())) hit = sum(a[i] == b[i] for i in range(4)) blow = sum(b[i] in a for i in range(4)) - hit print(hit, blow)
[["-", 64, 196, 0, 1, 0, 662, 12, 681, 0, 372], ["-", 64, 196, 0, 1, 0, 662, 12, 681, 28, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 147], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 146]]
5
98
6
# coding=utf-8 def hit_and_blow(answer: list, expect: list) -> tuple: hit, blow = 0, 0 for (i, j) in zip(answer, expect): if i == j: hit += 1 answer_set = set(answer) expect_set = set(expect) blow_set = answer_set & expect_set print(blow_set) blow = len(blow_set) - hit return hit, blow if __name__ == '__main__': while True: try: answer_number = list(map(int, input().split())) expected_number = list(map(int, input().split())) except EOFError: break h, b = hit_and_blow(answer_number, expected_number) print(h, b)
# coding=utf-8 def hit_and_blow(answer: list, expect: list) -> tuple: hit, blow = 0, 0 for (i, j) in zip(answer, expect): if i == j: hit += 1 answer_set = set(answer) expect_set = set(expect) blow_set = answer_set & expect_set blow = len(blow_set) - hit return hit, blow if __name__ == '__main__': while True: try: answer_number = list(map(int, input().split())) expected_number = list(map(int, input().split())) except EOFError: break h, b = hit_and_blow(answer_number, expected_number) print(h, b)
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
143
4
var f = []; function main() { var localInput = input; for (var y = -2; y < 12; y++) { f[y] = []; for (var x = -2; x < 12; x++) { f[y][x] = 0; // initialize:undefined -> 0 } } var len = localInput.length; for (; len--;) { var l = localInput[len]; eval("d" + localInput[len][4] + "(" + localInput[len][0] + "," + localInput[len][2] + ");"); } var nd = 0; // not dropped var md = 0; // most dropped var y = 10; for (; y--;) { var x = 10; for (; x--;) { nd += !(f[y][x]); md = mx(f[y][x], md); } } console.log(nd); console.log(md); } function d1(x, y) { f[y + 1][x]++; f[y][x - 1]++; f[y][x]++; f[y][x + 1]++; f[y - 1][x]++; } function d2(x, y) { d1(x, y); f[y + 1][x - 1]++; f[y + 1][x + 1]++; f[y - 1][x - 1]++; f[y - 1][x + 1]++; } function d3(x, y) { d2(x, y); f[y + 2][x]++; f[y - 2][x]++; f[y][x - 2]++; f[y][x + 2]++; } function mx(a, b) { var t = (a - b); return a - (t & (t >> 31)); } var input = ''; process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function(chunk) { input += chunk; }); process.stdin.on('end', function() { input = input.split('\n'); main(); });
var f = []; function main() { var localInput = input; for (var y = -2; y < 12; y++) { f[y] = []; for (var x = -2; x < 12; x++) { f[y][x] = 0; // initialize:undefined -> 0 } } var len = localInput.length - 1; for (; len--;) { var l = localInput[len]; eval("d" + localInput[len][4] + "(" + localInput[len][0] + "," + localInput[len][2] + ");"); } var nd = 0; // not dropped var md = 0; // most dropped var y = 10; for (; y--;) { var x = 10; for (; x--;) { nd += !(f[y][x]); md = mx(f[y][x], md); } } console.log(nd); console.log(md); } function d1(x, y) { f[y + 1][x]++; f[y][x - 1]++; f[y][x]++; f[y][x + 1]++; f[y - 1][x]++; } function d2(x, y) { d1(x, y); f[y + 1][x - 1]++; f[y + 1][x + 1]++; f[y - 1][x - 1]++; f[y - 1][x + 1]++; } function d3(x, y) { d2(x, y); f[y + 2][x]++; f[y - 2][x]++; f[y][x - 2]++; f[y][x + 2]++; } function mx(a, b) { var t = (a - b); return a - (t & (t >> 31)); } var input = ''; process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function(chunk) { input += chunk; }); process.stdin.on('end', function() { input = input.split('\n'); main(); });
[["+", 8, 556, 0, 198, 0, 200, 51, 16, 17, 33], ["+", 8, 556, 0, 198, 0, 200, 51, 16, 12, 555]]
2
519
2
import java.util.Scanner; public class Main { public static final int MAPSIZE = 10; public static void main(String[] args) { Scanner sc = new Scanner(System.in); /*we prepare bigger field*/ int[][] field = new int[MAPSIZE + 4][MAPSIZE + 4]; while (true) { /*get coordinates and magnitude of the ink*/ String[] input = sc.nextLine().split(","); /*if null input, break the loop*/ if (input.length == 1) { break; } /*parse the input data to integer*/ int x = Integer.parseInt(input[0]); int y = Integer.parseInt(input[1]); int size = Integer.parseInt(input[2]); /*drop the ink*/ drop(field, x, y, size); } // end of while loop /*only go through valid part of the field and count value with 0*/ int count = 0; int max = 0; for (int i = 2; i <= MAPSIZE + 1; i++) { for (int j = 2; j <= MAPSIZE + 1; j++) { if (field[i][j] == 0) { count++; } else if (field[i][j] > max) { max = field[i][j]; } } } /*print out the reuslt*/ System.out.println(count); System.out.println(max); } // end of main method public static void drop(int[][] field, int x, int y, int size) { switch (size) { case 1: dropMin(field, y, x); // because the array is configured differently, x // and y are switched. break; case 2: dropMiddle(field, y, x); break; case 3: dropMax(field, y, x); break; } } public static void dropMin(int[][] field, int x, int y) { field[x + 2][y + 2]++; // center field[x + 2][y + 1]++; // up field[x + 2][y + 3]++; // down field[x + 1][y + 2]++; // left field[x + 3][y + 2]++; // right } public static void dropMiddle(int[][] field, int x, int y) { dropMin(field, x, y); field[x + 3][y + 3]++; field[x + 3][y + 1]++; field[x + 1][y + 1]++; field[x + 1][y + 3]++; } public static void dropMax(int[][] field, int x, int y) { dropMiddle(field, x, y); field[x + 2][y]++; field[x + 2][y + 4]++; field[x][y + 2]++; field[x + 4][y + 2]++; } } // end of class
import java.util.Scanner; public class Main { public static final int MAPSIZE = 10; public static void main(String[] args) { Scanner sc = new Scanner(System.in); /*we prepare bigger field*/ int[][] field = new int[MAPSIZE + 4][MAPSIZE + 4]; while (sc.hasNext()) { /*get coordinates and magnitude of the ink*/ String[] input = sc.nextLine().split(","); /*if null input, break the loop*/ if (input.length == 1) { break; } /*parse the input data to integer*/ int x = Integer.parseInt(input[0]); int y = Integer.parseInt(input[1]); int size = Integer.parseInt(input[2]); /*drop the ink*/ drop(field, x, y, size); } // end of while loop /*only go through valid part of the field and count value with 0*/ int count = 0; int max = 0; for (int i = 2; i <= MAPSIZE + 1; i++) { for (int j = 2; j <= MAPSIZE + 1; j++) { if (field[i][j] == 0) { count++; } else if (field[i][j] > max) { max = field[i][j]; } } } /*print out the reuslt*/ System.out.println(count); System.out.println(max); } // end of main method public static void drop(int[][] field, int x, int y, int size) { switch (size) { case 1: dropMin(field, y, x); // because the array is configured differently, x // and y are switched. break; case 2: dropMiddle(field, y, x); break; case 3: dropMax(field, y, x); break; } } public static void dropMin(int[][] field, int x, int y) { field[x + 2][y + 2]++; // center field[x + 2][y + 1]++; // up field[x + 2][y + 3]++; // down field[x + 1][y + 2]++; // left field[x + 3][y + 2]++; // right } public static void dropMiddle(int[][] field, int x, int y) { dropMin(field, x, y); field[x + 3][y + 3]++; field[x + 3][y + 1]++; field[x + 1][y + 1]++; field[x + 1][y + 3]++; } public static void dropMax(int[][] field, int x, int y) { dropMiddle(field, x, y); field[x + 2][y]++; field[x + 2][y + 4]++; field[x][y + 2]++; field[x + 4][y + 2]++; } } // end of class
[["-", 0, 195, 8, 196, 0, 52, 15, 15, 0, 146], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 500, 22], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 0, 131], ["+", 8, 196, 0, 52, 15, 15, 0, 492, 141, 22], ["+", 0, 52, 15, 15, 0, 492, 3, 4, 0, 24], ["+", 0, 52, 15, 15, 0, 492, 3, 4, 0, 25]]
3
586
6
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { int field[][] = setField(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input = null; while (true) { try { input = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (input == null || input.isEmpty()) { break; }; String[] inputs = input.split(","); drop(field, Integer.parseInt(inputs[0]), Integer.parseInt(inputs[1]), Integer.parseInt(inputs[2])); } amountOfWhite(field); maxDepth(field); } private static int[][] setField() { int field[][] = new int[10][10]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { field[i][j] = 0; } } return field; } private static void drop(int[][] field, int x, int y, int size) { switch (size) { case 1: dropSmall(field, x, y); break; case 2: dropMiddle(field, x, y); break; case 3: dropLarge(field, x, y); break; } } private static void dropLarge(int[][] field, int x, int y) { dropMiddle(field, x, y); int dropX[] = {-2, 0, 2, 0}; int dropY[] = {0, -2, 0, 2}; for (int i = 0; i < dropX.length; i++) { dropping(field, x + dropX[i], y + dropY[i]); } } private static void dropMiddle(int[][] field, int x, int y) { dropSmall(field, x, y); int dropX[] = {-1, -1, 1, 1}; int dropY[] = {1, -1, 1, -1}; for (int i = 0; i < dropX.length; i++) { dropping(field, x + dropX[i], y + dropY[i]); } } private static void dropSmall(int[][] field, int x, int y) { int dropX[] = {-1, 0, 1, 0}; int dropY[] = {0, -1, 0, 1}; dropping(field, x, y); for (int i = 0; i < dropX.length; i++) { dropping(field, x + dropX[i], y + dropY[i]); } } private static int[][] dropping(int[][] field, int x, int y) { if (0 <= x || x < 10 || 0 <= y || y < 10) { field[x][y] += 1; } return field; } private static void amountOfWhite(int[][] field) { int count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (field[i][j] == 0) { count++; } } } System.out.println(count); } private static void maxDepth(int[][] field) { int maxDepth = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (maxDepth < field[i][j]) { maxDepth = field[i][j]; } } } System.out.println(maxDepth); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { int field[][] = setField(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input = null; while (true) { try { input = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (input == null || input.isEmpty()) { break; }; String[] inputs = input.split(","); drop(field, Integer.parseInt(inputs[0]), Integer.parseInt(inputs[1]), Integer.parseInt(inputs[2])); } amountOfWhite(field); maxDepth(field); } private static int[][] setField() { int field[][] = new int[10][10]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { field[i][j] = 0; } } return field; } private static void drop(int[][] field, int x, int y, int size) { switch (size) { case 1: dropSmall(field, x, y); break; case 2: dropMiddle(field, x, y); break; case 3: dropLarge(field, x, y); break; } } private static void dropLarge(int[][] field, int x, int y) { dropMiddle(field, x, y); int dropX[] = {-2, 0, 2, 0}; int dropY[] = {0, -2, 0, 2}; for (int i = 0; i < dropX.length; i++) { dropping(field, x + dropX[i], y + dropY[i]); } } private static void dropMiddle(int[][] field, int x, int y) { dropSmall(field, x, y); int dropX[] = {-1, -1, 1, 1}; int dropY[] = {1, -1, 1, -1}; for (int i = 0; i < dropX.length; i++) { dropping(field, x + dropX[i], y + dropY[i]); } } private static void dropSmall(int[][] field, int x, int y) { int dropX[] = {-1, 0, 1, 0}; int dropY[] = {0, -1, 0, 1}; dropping(field, x, y); for (int i = 0; i < dropX.length; i++) { dropping(field, x + dropX[i], y + dropY[i]); } } private static int[][] dropping(int[][] field, int x, int y) { if (0 <= x && x < 10 && 0 <= y && y < 10) { field[x][y] += 1; } return field; } private static void amountOfWhite(int[][] field) { int count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (field[i][j] == 0) { count++; } } } System.out.println(count); } private static void maxDepth(int[][] field) { int maxDepth = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (maxDepth < field[i][j]) { maxDepth = field[i][j]; } } } System.out.println(maxDepth); } }
[["-", 15, 15, 0, 16, 31, 16, 31, 16, 17, 106], ["+", 15, 15, 0, 16, 31, 16, 31, 16, 17, 98], ["-", 0, 57, 15, 15, 0, 16, 31, 16, 17, 106], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 98]]
3
833
68
import java.util.Scanner; public class Main { static int x, y, p, max = 0, minCount = 0; public static void main(String args[]) { int map[][] = new int[10][10]; Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String input[] = sc.next().split(","); x = Integer.parseInt(input[0]); y = Integer.parseInt(input[1]); p = Integer.parseInt(input[2]); map[x][y]++; if (judge(x + 1, y)) map[x + 1][y]++; if (judge(x - 1, y)) map[x - 1][y]++; if (judge(x, y - 1)) map[x][y - 1]++; if (judge(x, y + 1)) map[x][y + 1]++; if (p >= 2) { if (judge(x + 1, y + 1)) map[x + 1][y + 1]++; if (judge(x - 1, y - 1)) map[x - 1][y - 1]++; if (judge(x - 1, y + 1)) map[x - 1][y + 1]++; if (judge(x + 1, y - 1)) map[x + 1][y - 1]++; } if (p >= 3) { if (judge(x + 2, y)) map[x + 2][y]++; if (judge(x - 2, y)) map[x - 2][y]++; if (judge(x, y + 2)) map[x][y + 2]++; if (judge(x, y - 2)) map[x][y - 2]++; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (map[i][j] == 0) minCount++; if (map[i][j] > max) max = map[i][j]; } } System.out.println(minCount + " " + max); } public static boolean judge(int x, int y) { if (x < 0 || x > 9 || y < 0 || y > 9) return false; else return true; } }
import java.util.Scanner; public class Main { static int x, y, p, max = 0, minCount = 0; public static void main(String args[]) { int map[][] = new int[10][10]; Scanner sc = new Scanner(System.in); while (sc.hasNext()) { String input[] = sc.next().split(","); x = Integer.parseInt(input[0]); y = Integer.parseInt(input[1]); p = Integer.parseInt(input[2]); map[x][y]++; if (judge(x + 1, y)) map[x + 1][y]++; if (judge(x - 1, y)) map[x - 1][y]++; if (judge(x, y - 1)) map[x][y - 1]++; if (judge(x, y + 1)) map[x][y + 1]++; if (p >= 2) { if (judge(x + 1, y + 1)) map[x + 1][y + 1]++; if (judge(x - 1, y - 1)) map[x - 1][y - 1]++; if (judge(x - 1, y + 1)) map[x - 1][y + 1]++; if (judge(x + 1, y - 1)) map[x + 1][y - 1]++; } if (p >= 3) { if (judge(x + 2, y)) map[x + 2][y]++; if (judge(x - 2, y)) map[x - 2][y]++; if (judge(x, y + 2)) map[x][y + 2]++; if (judge(x, y - 2)) map[x][y - 2]++; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (map[i][j] == 0) minCount++; if (map[i][j] > max) max = map[i][j]; } } System.out.println(minCount + "\n" + max); } public static boolean judge(int x, int y) { if (x < 0 || x > 9 || y < 0 || y > 9) return false; else return true; } }
[["-", 3, 4, 0, 16, 31, 16, 12, 5, 0, 491], ["+", 3, 4, 0, 16, 31, 16, 12, 5, 0, 44]]
3
558
2
import java.util.Scanner; public class Main { public static void main(String[] args) { int[][] map = new int[10][10]; int ink[][][] = {{ {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }}; Scanner scanner = new Scanner(System.in); for (; scanner.hasNext();) { String str = scanner.next(); String[] num = str.split(","); int x = Integer.parseInt(num[0]); int y = Integer.parseInt(num[1]); int id = Integer.parseInt(num[2]) - 1; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { int px = x - 2 + i; int py = y - 2 + j; if ((0 <= px && px < 10) || (0 <= py && py < 10)) { map[px][py] += ink[id][i][j]; } } } } int count = 0; int max = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (map[i][j] == 0) { count++; } else if (map[i][j] > max) { max = map[i][j]; } } } System.out.println(count); System.out.println(max); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { int[][] map = new int[10][10]; int ink[][][] = {{ {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}, }, { {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }}; Scanner scanner = new Scanner(System.in); for (; scanner.hasNext();) { String str = scanner.next(); String[] num = str.split(","); int x = Integer.parseInt(num[0]); int y = Integer.parseInt(num[1]); int id = Integer.parseInt(num[2]) - 1; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { int px = x - 2 + i; int py = y - 2 + j; if ((0 <= px && px < 10) && (0 <= py && py < 10)) { map[px][py] += ink[id][i][j]; } } } } int count = 0; int max = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (map[i][j] == 0) { count++; } else if (map[i][j] > max) { max = map[i][j]; } } } System.out.println(count); System.out.println(max); } }
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 98]]
3
522
2
import java.util.Scanner; public class Main { private Scanner sc; public static void main(String[] args) { new Main(); } public Main() { sc = new Scanner(System.in); int[][] map = new int[10][10]; int[][][] drop = {{{0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}}, {{0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}}, {{0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}}}; while (sc.hasNextLine() == true) { String[] params = sc.nextLine().split(","); int x = Integer.parseInt(params[0]); int y = Integer.parseInt(params[1]); int d = Integer.parseInt(params[2]) - 1; for (int i = 0; i < 5; i++) { int xi = x + i - 2; if ((xi < 0) || (xi >= 10)) continue; for (int j = 0; j < 5; j++) { int yj = y + j - 2; if ((yj < 0) || (yj >= 10)) continue; map[xi][yj] = map[xi][yj] + drop[d][i][j]; } } int count = 0; int max = 0; for (int i = 0; i < map.length; i++) { for (int j = 0; j < map[0].length; j++) { if (map[i][j] == 0) count++; if (max < map[i][j]) max = map[i][j]; } } System.out.println(count); System.out.println(max); } } }
import java.util.Scanner; public class Main { private Scanner sc; public static void main(String[] args) { new Main(); } public Main() { sc = new Scanner(System.in); int[][] map = new int[10][10]; int[][][] drop = {{{0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}}, {{0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}}, {{0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}}}; while (sc.hasNextLine() == true) { String[] params = sc.nextLine().split(","); int x = Integer.parseInt(params[0]); int y = Integer.parseInt(params[1]); int d = Integer.parseInt(params[2]) - 1; for (int i = 0; i < 5; i++) { int xi = x + i - 2; if ((xi < 0) || (xi >= 10)) continue; for (int j = 0; j < 5; j++) { int yj = y + j - 2; if ((yj < 0) || (yj >= 10)) continue; map[xi][yj] = map[xi][yj] + drop[d][i][j]; } } } int count = 0; int max = 0; for (int i = 0; i < map.length; i++) { for (int j = 0; j < map[0].length; j++) { if (map[i][j] == 0) count++; if (max < map[i][j]) max = map[i][j]; } } System.out.println(count); System.out.println(max); } }
[["+", 0, 263, 8, 519, 0, 52, 8, 196, 0, 46], ["-", 0, 263, 8, 519, 0, 52, 8, 196, 0, 46]]
3
546
2
// 1=31,2=29,3=31,4=30,5=31,6=30,7=31,8=31,9=30,10=31,11=30,12=31// #include <iostream> #include <string> using namespace std; int main() { string str[7]{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuseday"}; int t[11]{31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; // 0 1 2 3 4 5 6 7 8 9 10// int d, m; while (cin >> m >> d) { if (m == 0) break; if (m == 1) cout << str[d % 7] << endl; else { d = d + t[m - 2]; cout << str[d % 7] << endl; } } return 0; }
// 1=31,2=29,3=31,4=30,5=31,6=30,7=31,8=31,9=30,10=31,11=30,12=31// #include <iostream> #include <string> using namespace std; int main() { string str[7]{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int t[11]{31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; // 0 1 2 3 4 5 6 7 8 9 10// int d, m; while (cin >> m >> d) { if (m == 0) break; if (m == 1) cout << str[d % 7] << endl; else { d = d + t[m - 2]; cout << str[d % 7] << endl; } } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
148
2
#include <iostream> using namespace std; int main() { int date, month, day; while (cin >> month >> day && month != 0) { switch (month) { case 1: switch (date % 7) { case 1: day = 4; break; case 2: day = 5; break; case 3: day = 6; break; case 4: day = 7; break; case 5: day = 1; break; case 6: day = 2; break; case 0: day = 3; break; } break; case 2: switch (date % 7) { case 1: day = 7; break; case 2: day = 1; break; case 3: day = 2; break; case 4: day = 3; break; case 5: day = 4; break; case 6: day = 5; break; case 0: day = 6; break; } break; case 3: switch (date % 7) { case 1: day = 1; break; case 2: day = 2; break; case 3: day = 3; break; case 4: day = 4; break; case 5: day = 5; break; case 6: day = 6; break; case 0: day = 7; break; } break; case 4: switch (date % 7) { case 1: day = 4; break; case 2: day = 5; break; case 3: day = 6; break; case 4: day = 7; break; case 5: day = 1; break; case 6: day = 2; break; case 0: day = 3; break; } break; case 5: switch (date % 7) { case 1: day = 6; break; case 2: day = 7; break; case 3: day = 1; break; case 4: day = 2; break; case 5: day = 3; break; case 6: day = 4; break; case 0: day = 5; break; } break; case 6: switch (date % 7) { case 1: day = 2; break; case 2: day = 3; break; case 3: day = 4; break; case 4: day = 5; break; case 5: day = 6; break; case 6: day = 7; break; case 0: day = 1; break; } break; case 7: switch (date % 7) { case 1: day = 4; break; case 2: day = 5; break; case 3: day = 6; break; case 4: day = 7; break; case 5: day = 1; break; case 6: day = 2; break; case 0: day = 3; break; } break; case 8: switch (date % 7) { case 1: day = 7; break; case 2: day = 1; break; case 3: day = 2; break; case 4: day = 3; break; case 5: day = 4; break; case 6: day = 5; break; case 0: day = 6; break; } break; case 9: switch (date % 7) { case 1: day = 3; break; case 2: day = 4; break; case 3: day = 5; break; case 4: day = 6; break; case 5: day = 7; break; case 6: day = 1; break; case 0: day = 2; break; } break; case 10: switch (date % 7) { case 1: day = 5; break; case 2: day = 6; break; case 3: day = 7; break; case 4: day = 1; break; case 5: day = 2; break; case 6: day = 3; break; case 0: day = 4; break; } break; case 11: switch (date % 7) { case 1: day = 1; break; case 2: day = 2; break; case 3: day = 3; break; case 4: day = 4; break; case 5: day = 5; break; case 6: day = 6; break; case 0: day = 7; break; } break; case 12: switch (date % 7) { case 1: day = 3; break; case 2: day = 4; break; case 3: day = 5; break; case 4: day = 6; break; case 5: day = 7; break; case 6: day = 1; break; case 0: day = 2; break; } break; } switch (day) { case 1: cout << "Monday" << endl; break; case 2: cout << "Tuesday" << endl; break; case 3: cout << "Wednesday" << endl; break; case 4: cout << "Thursday" << endl; break; case 5: cout << "Friday" << endl; break; case 6: cout << "Saturday" << endl; break; case 7: cout << "Sunday" << endl; break; } } return 0; }
#include <iostream> using namespace std; int main() { int date, month, day; while (cin >> month >> date && month != 0) { switch (month) { case 1: switch (date % 7) { case 1: day = 4; break; case 2: day = 5; break; case 3: day = 6; break; case 4: day = 7; break; case 5: day = 1; break; case 6: day = 2; break; case 0: day = 3; break; } break; case 2: switch (date % 7) { case 1: day = 7; break; case 2: day = 1; break; case 3: day = 2; break; case 4: day = 3; break; case 5: day = 4; break; case 6: day = 5; break; case 0: day = 6; break; } break; case 3: switch (date % 7) { case 1: day = 1; break; case 2: day = 2; break; case 3: day = 3; break; case 4: day = 4; break; case 5: day = 5; break; case 6: day = 6; break; case 0: day = 7; break; } break; case 4: switch (date % 7) { case 1: day = 4; break; case 2: day = 5; break; case 3: day = 6; break; case 4: day = 7; break; case 5: day = 1; break; case 6: day = 2; break; case 0: day = 3; break; } break; case 5: switch (date % 7) { case 1: day = 6; break; case 2: day = 7; break; case 3: day = 1; break; case 4: day = 2; break; case 5: day = 3; break; case 6: day = 4; break; case 0: day = 5; break; } break; case 6: switch (date % 7) { case 1: day = 2; break; case 2: day = 3; break; case 3: day = 4; break; case 4: day = 5; break; case 5: day = 6; break; case 6: day = 7; break; case 0: day = 1; break; } break; case 7: switch (date % 7) { case 1: day = 4; break; case 2: day = 5; break; case 3: day = 6; break; case 4: day = 7; break; case 5: day = 1; break; case 6: day = 2; break; case 0: day = 3; break; } break; case 8: switch (date % 7) { case 1: day = 7; break; case 2: day = 1; break; case 3: day = 2; break; case 4: day = 3; break; case 5: day = 4; break; case 6: day = 5; break; case 0: day = 6; break; } break; case 9: switch (date % 7) { case 1: day = 3; break; case 2: day = 4; break; case 3: day = 5; break; case 4: day = 6; break; case 5: day = 7; break; case 6: day = 1; break; case 0: day = 2; break; } break; case 10: switch (date % 7) { case 1: day = 5; break; case 2: day = 6; break; case 3: day = 7; break; case 4: day = 1; break; case 5: day = 2; break; case 6: day = 3; break; case 0: day = 4; break; } break; case 11: switch (date % 7) { case 1: day = 1; break; case 2: day = 2; break; case 3: day = 3; break; case 4: day = 4; break; case 5: day = 5; break; case 6: day = 6; break; case 0: day = 7; break; } break; case 12: switch (date % 7) { case 1: day = 3; break; case 2: day = 4; break; case 3: day = 5; break; case 4: day = 6; break; case 5: day = 7; break; case 6: day = 1; break; case 0: day = 2; break; } break; } switch (day) { case 1: cout << "Monday" << endl; break; case 2: cout << "Tuesday" << endl; break; case 3: cout << "Wednesday" << endl; break; case 4: cout << "Thursday" << endl; break; case 5: cout << "Friday" << endl; break; case 6: cout << "Saturday" << endl; break; case 7: cout << "Sunday" << endl; break; } } return 0; }
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22]]
1
1,051
2
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string youbi[7] = {"Tursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (1) { int m, d, s = 0; cin >> m >> d; if (!m && !d) break; for (int i = 0; i < m - 1; i++) s += days[i]; s += d; cout << youbi[(s - 1) % 7] << endl; } return 0; }
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string youbi[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; while (1) { int m, d, s = 0; cin >> m >> d; if (!m && !d) break; for (int i = 0; i < m - 1; i++) s += days[i]; s += d; cout << youbi[(s - 1) % 7] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
160
2
#include <bits/stdc++.h> using namespace std; int main() { for (;;) { int m, d; cin >> m >> d; if (m == 0) break; vector<int> day = {31, 29, 31, 30, 31, 30, 31, 30, 31, 30, 30, 31}; int tmp = d; for (int i = 0; i < m - 1; i++) { tmp += day.at(i); } int ans = tmp % 7; vector<string> week = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; cout << week.at(ans) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { for (;;) { int m, d; cin >> m >> d; if (m == 0) break; vector<int> day = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int tmp = d; for (int i = 0; i < m - 1; i++) { tmp += day.at(i); } int ans = tmp % 7; vector<string> week = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; cout << week.at(ans) << endl; } }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
156
4
#include <iostream> using namespace std; int main() { int month, day; cin >> month >> day; while (month != 0 && day != 0) { if (month >= 1) day = day; if (month >= 2) day = day + 31; if (month >= 3) day = day + 28; if (month >= 4) day = day + 31; if (month >= 5) day = day + 30; if (month >= 6) day = day + 31; if (month >= 7) day = day + 30; if (month >= 8) day = day + 31; if (month >= 9) day = day + 31; if (month >= 10) day = day + 30; if (month >= 11) day = day + 31; if (month >= 12) day = day + 30; if (day % 7 == 0) cout << "Wednesday" << endl; if (day % 7 == 1) cout << "Thursday" << endl; if (day % 7 == 2) cout << "Friday" << endl; if (day % 7 == 3) cout << "Saturday" << endl; if (day % 7 == 4) cout << "Sunday" << endl; if (day % 7 == 5) cout << "Monday" << endl; if (day % 7 == 6) cout << "Tuesday" << endl; cin >> month >> day; } return 0; }
#include <iostream> using namespace std; int main() { int month, day; cin >> month >> day; while (month != 0 && day != 0) { if (month >= 1) day = day; if (month >= 2) day = day + 31; if (month >= 3) day = day + 29; if (month >= 4) day = day + 31; if (month >= 5) day = day + 30; if (month >= 6) day = day + 31; if (month >= 7) day = day + 30; if (month >= 8) day = day + 31; if (month >= 9) day = day + 31; if (month >= 10) day = day + 30; if (month >= 11) day = day + 31; if (month >= 12) day = day + 30; if (day % 7 == 0) cout << "Wednesday" << endl; if (day % 7 == 1) cout << "Thursday" << endl; if (day % 7 == 2) cout << "Friday" << endl; if (day % 7 == 3) cout << "Saturday" << endl; if (day % 7 == 4) cout << "Sunday" << endl; if (day % 7 == 5) cout << "Monday" << endl; if (day % 7 == 6) cout << "Tuesday" << endl; cin >> month >> day; } return 0; }
[["-", 0, 57, 64, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 13]]
1
298
2
#include <iostream> using namespace std; int main() { int m, d; while (cin >> m >> d) { if (!m) break; int daym[12] = {0, 31, 60, 91, 121, 152, 183, 213, 244, 274, 305, 335}; int wd = (daym[m - 1] + d + 2) % 7; switch (wd) { case 0: cout << "Monday" << endl; break; case 1: cout << "Tuesday" << endl; break; case 2: cout << "Wednesday" << endl; break; case 3: cout << "Thursday" << endl; break; case 4: cout << "Friday" << endl; break; case 5: cout << "Saturday" << endl; break; case 6: cout << "Sunday" << endl; break; } } return 0; }
#include <iostream> using namespace std; int main() { int m, d; while (cin >> m >> d) { if (!m) break; int daym[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; int wd = (daym[m - 1] + d + 2) % 7; switch (wd) { case 0: cout << "Monday" << endl; break; case 1: cout << "Tuesday" << endl; break; case 2: cout << "Wednesday" << endl; break; case 3: cout << "Thursday" << endl; break; case 4: cout << "Friday" << endl; break; case 5: cout << "Saturday" << endl; break; case 6: cout << "Sunday" << endl; break; } } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
184
2
#include <stdio.h> void y(int x) { if (x == 0) puts("Thursday"); else if (x == 1) puts("Friday"); else if (x == 2) puts("Suturday"); else if (x == 3) puts("Sunday"); else if (x == 4) puts("Monday"); else if (x == 5) puts("Tuesday"); else if (x == 6) puts("Wednesday"); } int main(void) { int M, D; while (1) { int date = 0, ans; int m[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; scanf("%d%d", &M, &D); if (M == 0 && D == 0) break; for (int i = 1; i <= 12; i++) { for (int j = 1; j <= m[i - 1]; j++) { if (i == M && j == D) { ans = date; } // printf("%dŒŽ%d“ú",i,j); // y(date%7); date++; } } y(ans % 7); } return 0; }
#include <stdio.h> void y(int x) { if (x == 0) puts("Thursday"); else if (x == 1) puts("Friday"); else if (x == 2) puts("Saturday"); else if (x == 3) puts("Sunday"); else if (x == 4) puts("Monday"); else if (x == 5) puts("Tuesday"); else if (x == 6) puts("Wednesday"); } int main(void) { int M, D; while (1) { int date = 0, ans; int m[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; scanf("%d%d", &M, &D); if (M == 0 && D == 0) break; for (int i = 1; i <= 12; i++) { for (int j = 1; j <= m[i - 1]; j++) { if (i == M && j == D) { ans = date; } // printf("%dŒŽ%d“ú%d\n",i,j,date%7); // y(date%7); date++; } } y(ans % 7); } return 0; }
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
257
2
#include <iostream> #include <string> using namespace std; int main() { int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string youbi[7] = {"Monsay", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (1) { int mon, day; cin >> mon >> day; if (mon == 0) break; int sum = 0; for (int i = 0; i < mon - 1; i++) { sum += days[i]; } sum += day; cout << youbi[(sum + 2) % 7] << endl; } return 0; }
#include <iostream> #include <string> using namespace std; int main() { int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; while (1) { int mon, day; cin >> mon >> day; if (mon == 0) break; int sum = 0; for (int i = 0; i < mon - 1; i++) { sum += days[i]; } sum += day; cout << youbi[(sum + 2) % 7] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
159
2
#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<int> r; string d[7] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}; while (true) { int m, d; cin >> m >> d; if (m == 0) break; if (m < 3) m += 12; d -= 2; r.push_back((5 + d + (13 * (m + 1)) / 5) % 7); } for (int i = 0; i < r.size(); i++) { cout << d[r[i]] << endl; } return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<int> r; string d[7] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}; while (true) { int m, d; cin >> m >> d; if (m == 0) break; if (m < 3) { m += 12; d -= 2; } r.push_back((5 + d + (13 * (m + 1)) / 5) % 7); } for (int i = 0; i < r.size(); i++) { cout << d[r[i]] << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
1
157
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define all(c) (c).begin(), (c).end() #define pb push_back #define mp make_pair #define EXIST(v, i) (find(all(v), i) != (v).end()) #define ERASE(v, i) (v).erase(remove(all(v), i), (v).end()) #define INDEX(v, i) (find(all(v), i) - (v).begin()) #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define debug(x) cerr << #x << " = " << (x) << endl; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } const int INF = 100000000; const double PI = 3.14159265358979323846; const double EPS = 1e-10; int main() { int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string week[] = {"Wednexday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; for (int month, day; cin >> month >> day && month && day;) { int sum = 0; rep(i, month - 1) { sum += days[i]; } sum += day; sum %= 7; cout << week[sum] << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define all(c) (c).begin(), (c).end() #define pb push_back #define mp make_pair #define EXIST(v, i) (find(all(v), i) != (v).end()) #define ERASE(v, i) (v).erase(remove(all(v), i), (v).end()) #define INDEX(v, i) (find(all(v), i) - (v).begin()) #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define debug(x) cerr << #x << " = " << (x) << endl; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } const int INF = 100000000; const double PI = 3.14159265358979323846; const double EPS = 1e-10; int main() { int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string week[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; for (int month, day; cin >> month >> day && month && day;) { int sum = 0; rep(i, month - 1) { sum += days[i]; } sum += day; sum %= 7; cout << week[sum] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
310
2
#include <iostream> using namespace std; int main(void) { int m, d; while (1) { cin >> m >> d; if (m == 0) break; for (int i = m; i > 1; i--) { if (i - 1 == 4 || i - 1 == 6 || i - 1 == 9 || i - 1 == 11) d += 30; else if (i - 1 == 2) d += 29; else if (i - 1 == 1 || i - 1 == 3 || i - 1 == 5 || i - 1 == 7 || i - 1 == 8 || i - 1 == 10) d += 31; } if (d % 7 == 1) cout << "Thursday" << endl; if (d % 7 == 2) cout << "Friday" << endl; if (d % 7 == 3) cout << "Saturday" << endl; if (d % 7 == 4) cout << "Sunday" << endl; if (d % 7 == 5) cout << "Monday" << endl; if (d % 7 == 6) cout << "Tuesday" << endl; if (d % 7 == 7) cout << "Wednesday" << endl; } return 0; }
#include <iostream> using namespace std; int main(void) { int m, d; while (1) { cin >> m >> d; if (m == 0) break; for (int i = m; i > 1; i--) { if (i - 1 == 4 || i - 1 == 6 || i - 1 == 9 || i - 1 == 11) d += 30; else if (i - 1 == 2) d += 29; else if (i - 1 == 1 || i - 1 == 3 || i - 1 == 5 || i - 1 == 7 || i - 1 == 8 || i - 1 == 10) d += 31; } if (d % 7 == 1) cout << "Thursday" << endl; if (d % 7 == 2) cout << "Friday" << endl; if (d % 7 == 3) cout << "Saturday" << endl; if (d % 7 == 4) cout << "Sunday" << endl; if (d % 7 == 5) cout << "Monday" << endl; if (d % 7 == 6) cout << "Tuesday" << endl; if (d % 7 == 0) cout << "Wednesday" << endl; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
255
2
#include <iostream> using namespace std; int main() { int n, m; int x[12] = {0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 0}; while (cin >> n >> m, n || m) { if ((m + x[n - 1]) % 7 == 1) cout << "Thursday" << endl; if ((m + x[n - 1]) % 7 == 2) cout << "Friday" << endl; if ((m + x[n - 1]) % 7 == 3) cout << "Saturday" << endl; if ((m + x[n - 1]) % 7 == 4) cout << "Sunday" << endl; if ((m + x[n - 1]) % 7 == 5) cout << "Monday" << endl; if ((m + x[n - 1]) % 7 == 6) cout << "Tuesday" << endl; if ((m + x[n - 1]) % 7 == 0) cout << "Wednesday" << endl; } return 0; }
#include <iostream> using namespace std; int main() { int n, m; int x[12] = {0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6}; while (cin >> n >> m, n || m) { if ((m + x[n - 1]) % 7 == 1) cout << "Thursday" << endl; if ((m + x[n - 1]) % 7 == 2) cout << "Friday" << endl; if ((m + x[n - 1]) % 7 == 3) cout << "Saturday" << endl; if ((m + x[n - 1]) % 7 == 4) cout << "Sunday" << endl; if ((m + x[n - 1]) % 7 == 5) cout << "Monday" << endl; if ((m + x[n - 1]) % 7 == 6) cout << "Tuesday" << endl; if ((m + x[n - 1]) % 7 == 0) cout << "Wednesday" << endl; } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
241
2
#include <iostream> using namespace std; int main() { int a, b; int day[12] = {0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6}; while (cin >> a >> b, a || b) { b += day[a - 1]; switch (b % 7) { case 0: cout << "" << endl; break; case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; } } }
#include <iostream> using namespace std; int main() { int a, b; int day[12] = {0, 3, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6}; while (cin >> a >> b, a || b) { b += day[a - 1]; switch (b % 7) { case 0: cout << "Wednesday" << endl; break; case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; } } }
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
170
1
//曜日を当てる #include <cstdio> #include <string> using namespace std; int main(void) { string name[7] = {"Mondey", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int mond[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month, day, m, c; int i; //ループカウンタ while (1) { scanf("%d %d", &month, &day); if (month == 0) break; m = 1; //月の始めの一月 c = 3; //始まりは木曜日 while (1) { for (i = 1; i <= mond[m - 1]; i++, c++) if (month == m && i == day) break; if (month == m && i == day) break; m++; } printf("%s\n", name[c % 7].c_str()); } return 0; }
//曜日を当てる #include <cstdio> #include <string> using namespace std; int main(void) { string name[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int mond[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int month, day, m, c; int i; //ループカウンタ while (1) { scanf("%d %d", &month, &day); if (month == 0) break; m = 1; //月の始めの一月 c = 3; //始まりは木曜日 while (1) { for (i = 1; i <= mond[m - 1]; i++, c++) if (month == m && i == day) break; if (month == m && i == day) break; m++; } printf("%s\n", name[c % 7].c_str()); } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
210
2
#include <iostream> using namespace std; int main() { int monthNum[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string dayName[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; int month, day, passDay = 0; while (1) { cin >> month; cin >> day; if (month == 0) break; for (int i = 0; i < month; i++) passDay += monthNum[i]; passDay += day - 1; cout << dayName[passDay % 7] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int monthNum[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string dayName[7] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"}; int month, day, passDay = 0; while (1) { cin >> month >> day; if (month == 0) break; for (int i = 0; i < month; i++) passDay += monthNum[i]; passDay += day - 1; cout << dayName[passDay % 7] << endl; passDay = 0; } return 0; }
[["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
154
6
#include <iostream> #include <string> using namespace std; int main() { // arrays with number of days in month and the days names int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string week[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int month, day; while (cin >> month >> day) // entering day { int n = 0; for (int i = 1; i < month; i++) { n += days[i - 1]; } n += day; n %= 7; cout << week[n] << endl; // printing the day } return 0; }
#include <iostream> #include <string> using namespace std; int main() { // arrays with number of days in month and the days names int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string week[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int month, day; while (cin >> month >> day, month || day) // entering day { int n = 0; for (int i = 1; i < month; i++) { n += days[i - 1]; } n += day; n %= 7; cout << week[n] << endl; // printing the day } return 0; }
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]]
1
149
4
#include <iostream> using namespace std; int main() { int a[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n, m, d; while (cin >> n >> m, n, m) { d = 0; for (int i = 0; i < n - 1; i++) d = a[i] + d; d = d + m; while (d > 6) d -= 7; if (d == 5) cout << "Monday" << endl; else if (d == 5) cout << "Tuesday" << endl; else if (d == 0) cout << "Wednesday" << endl; else if (d == 1) cout << "Thursday" << endl; else if (d == 2) cout << "Friday" << endl; else if (d == 3) cout << "Saturday" << endl; else if (d == 4) cout << "Sunday" << endl; } }
#include <iostream> using namespace std; int main() { int a[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n, m, d; while (cin >> n >> m, n, m) { d = 0; for (int i = 0; i < n - 1; i++) d = a[i] + d; d = d + m; while (d > 6) d -= 7; if (d == 5) cout << "Monday" << endl; else if (d == 6) cout << "Tuesday" << endl; else if (d == 0) cout << "Wednesday" << endl; else if (d == 1) cout << "Thursday" << endl; else if (d == 2) cout << "Friday" << endl; else if (d == 3) cout << "Saturday" << endl; else if (d == 4) cout << "Sunday" << endl; } }
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13]]
1
214
2