結果

問題 No.7 プライムナンバーゲーム
ユーザー 👑 tatt61880tatt61880
提出日時 2019-03-23 22:46:31
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 7,268 ms
コンパイル使用メモリ 148,756 KB
実行使用メモリ 6,696 KB
最終ジャッジ日時 2024-04-09 04:35:58
合計ジャッジ時間 3,155 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,688 KB
testcase_01 AC 1 ms
6,692 KB
testcase_02 AC 4 ms
6,692 KB
testcase_03 AC 2 ms
6,692 KB
testcase_04 AC 1 ms
6,692 KB
testcase_05 AC 1 ms
6,692 KB
testcase_06 AC 3 ms
6,692 KB
testcase_07 AC 2 ms
6,692 KB
testcase_08 AC 2 ms
6,692 KB
testcase_09 AC 3 ms
6,696 KB
testcase_10 AC 1 ms
6,692 KB
testcase_11 AC 2 ms
6,692 KB
testcase_12 AC 3 ms
6,692 KB
testcase_13 AC 3 ms
6,692 KB
testcase_14 AC 5 ms
6,692 KB
testcase_15 AC 4 ms
6,692 KB
testcase_16 AC 4 ms
6,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var N: int :: cui@input().toInt(&)
	var dp: []bool :: #[N + 1]bool
	var primesList: list<int> :: #list<int>
	for i(2, N)
		if(math@prime(i))
			do primesList.add(i)
		end if
	end for
	var primes: []int :: primesList.toArray()
	
	do dp[0] :: true
	do dp[1] :: true
	for n(2, N)
		var val: bool :: false
		for id(0, ^primes - 1)
			if(primes[id] > n)
				break id
			end if
			if(!dp[n - primes[id]])
				do val :: true
				break id
			end if
		end for
		do dp[n] :: val
	end for
	var ans: bool :: dp[N]
	do cui@print(ans ?("Win\n", "Lose\n"))
end func
0