/* -*- coding: utf-8 -*- * * 361.cc: No.361 門松ゲーム2 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_L = 500; /* typedef */ /* global variables */ int grndys[MAX_L + 1]; bool used[MAX_L + 1]; /* subroutines */ /* main */ int main() { int l, d; cin >> l >> d; for (int k = 6; k <= l; k++) { memset(used, false, sizeof(used)); int maxl1 = k / 3; for (int l1 = 1; l1 < maxl1; l1++) { int maxl2 = (k + 1 - l1) / 2; for (int l2 = l1 + 1; l2 < maxl2; l2++) { int l3 = k - (l1 + l2); if (l3 <= l1 + d) used[grndys[l1] ^ grndys[l2] ^ grndys[l3]] = true; } } int g = 0; while (used[g]) g++; grndys[k] = g; } //printf("%d\n", grndys[l]); cout << (grndys[l] != 0 ? "kado" : "matsu") << endl; return 0; }