結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | iicafiaxus |
提出日時 | 2016-08-29 23:55:26 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 719 bytes |
コンパイル時間 | 701 ms |
コンパイル使用メモリ | 107,604 KB |
実行使用メモリ | 4,372 KB |
最終ジャッジ日時 | 2023-09-02 21:34:54 |
合計ジャッジ時間 | 1,757 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
4,368 KB |
testcase_01 | AC | 6 ms
4,372 KB |
testcase_02 | AC | 6 ms
4,368 KB |
testcase_03 | AC | 6 ms
4,368 KB |
testcase_04 | AC | 6 ms
4,368 KB |
testcase_05 | AC | 6 ms
4,372 KB |
testcase_06 | AC | 6 ms
4,368 KB |
testcase_07 | AC | 6 ms
4,368 KB |
testcase_08 | AC | 6 ms
4,372 KB |
testcase_09 | AC | 6 ms
4,368 KB |
testcase_10 | AC | 6 ms
4,372 KB |
testcase_11 | AC | 7 ms
4,372 KB |
testcase_12 | AC | 7 ms
4,372 KB |
testcase_13 | AC | 7 ms
4,368 KB |
testcase_14 | AC | 7 ms
4,372 KB |
testcase_15 | AC | 6 ms
4,368 KB |
testcase_16 | AC | 6 ms
4,372 KB |
ソースコード
import std.stdio; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; void main(){ int n = readln.chomp.to!int; int[] ps; bool[] flags; flags.length = 10009; foreach(i; 2 .. 109){ for(int j = 2 * i; j < 10009; j += i) flags[j] = 1; } foreach(j; 2 .. 10009){ if(!flags[j]) ps ~= j; } int[] xs; xs.length = 10009; xs[0] = 1; xs[1] = 1; for(int k = 0; k < 10009; k ++){ if(xs[k] != 0) continue; foreach(p; ps){ if(k - p < 0){ xs[k] = -1; break; } else if(xs[k - p] == -1){ xs[k] = 1; break; } } } string ans; if(xs[n] == 1) ans = "Win"; else ans = "Lose"; ans.writeln; }