No.361 Kadomatsu Game 2
レベル :
/ AI推定難易度 : 1225
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 256 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 113
作問者 :
koyumeishi
/ テスター :
🐬hec
タグ : / 解いたユーザー数 113
作問者 :
koyumeishi
/ テスター :
🐬hec
問題文最終更新日: 2026-06-25 18:48:29
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder 門松コンテスト
(順位表)
の他の問題:
Problem Statement
kado and matsu play a game in which they split bamboo to make kadomatsu.The game proceeds as follows.
- Initially, there is one piece of bamboo of length $L$ on the field.
-
The player whose turn it is chooses one piece of bamboo from the field and splits it into three pieces so that a kadomatsu can be made.
The chosen piece is removed from the field, and the three pieces resulting from the split are added to the field.
Here, letting $L$ be the length of the bamboo before the split and $L_1,L_2,L_3$ be the lengths of the pieces after the split, all of the following must be satisfied:- $L_1+L_2+L_3=L$
- $L_1 \neq L_2, L_2 \neq L_3, L_3 \neq L_1$
- $L_1,L_2,L_3$ are positive integers
- $max(L_1,L_2,L_3)-min(L_1,L_2,L_3) \leq D$
After splitting, the turn passes to the other player. If the player whose turn it is cannot split any bamboo so as to satisfy the conditions, that player loses. - The player who did not lose wins.
If both play optimally, who will win?
Input
L D
$L,D$ are integers satisfying the following.
$1 \leq D \leq L \leq 500$
Output
Print the name of the player who will win.
Sample
Sample 1
Input
7 3
Output
kado
If kado splits {7} -> {1,2,4}, the second player matsu cannot do anything and loses.
Sample 2
Input
7 2
Output
matsu
No split satisfying the conditions is possible from the start. {7} -> {1,2,4} is not allowed because max(1,2,4) - min(1,2,4) = 3 > D = 2.
Sample 3
Input
13 13
Output
matsu
The first player, kado, chooses one of the following ways to split:
{13} -> {1,2,10},{1,3,9},{1,4,8},{1,5,7},{2,3,8},{2,4,7},{2,5,6},{3,4,6}
and performs that split.
Bamboo of lengths 1 to 5 cannot be split any further so as to satisfy the conditions, so the second player, matsu, must split the longest piece.
- {6} -> {1,2,3}
- {7} -> {1,2,4}
- {8} -> {1,2,5},{1,3,4}
- {9} -> {1,2,6},{1,3,5},{2,3,4}
- {10} -> {1,2,7},{1,3,6},{1,4,5},{2,3,5}
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。