結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
|
提出日時 | 2015-06-05 13:20:49 |
言語 | PHP (7.2.24) |
結果 |
WA
|
実行時間 | - |
コード長 | 701 bytes |
コンパイル時間 | 606 ms |
コンパイル使用メモリ | 18,828 KB |
実行使用メモリ | 19,056 KB |
最終ジャッジ日時 | 2023-09-20 19:14:29 |
合計ジャッジ時間 | 1,902 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
18,964 KB |
testcase_01 | AC | 16 ms
18,896 KB |
testcase_02 | AC | 23 ms
18,968 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 16 ms
18,988 KB |
testcase_06 | AC | 19 ms
18,876 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 20 ms
18,820 KB |
testcase_10 | WA | - |
testcase_11 | AC | 18 ms
18,824 KB |
testcase_12 | WA | - |
testcase_13 | AC | 21 ms
18,824 KB |
testcase_14 | AC | 22 ms
18,728 KB |
testcase_15 | AC | 22 ms
18,884 KB |
testcase_16 | WA | - |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $starttime = microtime(TRUE); $n = trim(fgets(STDIN)); $prime_array = array(); for ( $i=2; $i<=$n; $i++ ) { if ( is_prime($i) ) { $prime_array[] = $i; } } $sub_count = 0; while ( $n >= 4 ) { for ( $i=(count($prime_array)-1); $i>=0; $i-- ) { if ( ($n - $prime_array[$i]) >= 2 ) { break; } } $n -= $prime_array[$i]; $sub_count++; } fprintf(STDERR, "sub_count: %d\n", $sub_count); if ( $sub_count % 2 ) { echo "Win".PHP_EOL; } else { echo "Lose".PHP_EOL; } function is_prime($number) { for ( $i=2; $i<=sqrt($number); $i++ ) { if ( !($number % $i) ) { return FALSE; } } return TRUE; } $exectime = microtime(TRUE) - $starttime; fprintf(STDERR,"%f seconds\n", $exectime);