結果

問題 No.361 門松ゲーム2
ユーザー 37zigen37zigen
提出日時 2016-05-29 18:16:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 2,445 ms
コンパイル使用メモリ 79,928 KB
実行使用メモリ 46,284 KB
最終ジャッジ日時 2024-04-16 18:16:40
合計ジャッジ時間 8,574 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,304 KB
testcase_01 AC 114 ms
40,412 KB
testcase_02 AC 131 ms
41,452 KB
testcase_03 AC 129 ms
41,392 KB
testcase_04 AC 119 ms
40,384 KB
testcase_05 AC 129 ms
41,292 KB
testcase_06 AC 128 ms
41,248 KB
testcase_07 AC 131 ms
41,196 KB
testcase_08 AC 131 ms
41,608 KB
testcase_09 AC 153 ms
41,532 KB
testcase_10 AC 131 ms
41,508 KB
testcase_11 AC 132 ms
41,132 KB
testcase_12 AC 147 ms
41,392 KB
testcase_13 AC 136 ms
41,344 KB
testcase_14 AC 276 ms
43,500 KB
testcase_15 AC 159 ms
41,792 KB
testcase_16 AC 269 ms
43,432 KB
testcase_17 AC 238 ms
42,952 KB
testcase_18 AC 178 ms
41,544 KB
testcase_19 AC 215 ms
42,920 KB
testcase_20 AC 160 ms
41,948 KB
testcase_21 AC 261 ms
43,328 KB
testcase_22 AC 376 ms
46,284 KB
testcase_23 AC 213 ms
41,892 KB
testcase_24 AC 214 ms
42,260 KB
testcase_25 AC 203 ms
42,312 KB
testcase_26 AC 250 ms
43,288 KB
testcase_27 AC 263 ms
43,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int L=sc.nextInt();
		int D=sc.nextInt();
		int[] g=new int[L+1];
		//g[i]=長さiの竹のみがあるとき、勝つことができるか。
		for(int len=1;len<=L;len++){
			HashSet<Integer> hs=new HashSet<>();
			out:for(int i=1;3*i<len;i++){
				for(int j=i+1;i+2*j<len;j++){
					//k>j,len-i-j>j,len>i+2*j
					int k=len-i-j;
					if(k-i<=D){
						hs.add(g[i]^g[j]^g[k]);
					}
				}
			}
			for(int i=0;;i++){
				if(!hs.contains(i)){
					g[len]=i;
					break;
				}
			}
		}
		System.out.println(g[L]!=0?"kado":"matsu");
	}
	void tr(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
}
0