結果

問題 No.7 プライムナンバーゲーム
ユーザー けむけむけむけむ
提出日時 2021-06-27 21:49:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 355 ms / 5,000 ms
コード長 691 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-09 05:04:43
合計ジャッジ時間 3,208 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 189 ms
11,648 KB
testcase_03 AC 42 ms
11,008 KB
testcase_04 AC 34 ms
10,880 KB
testcase_05 AC 35 ms
10,752 KB
testcase_06 AC 83 ms
11,136 KB
testcase_07 AC 64 ms
11,136 KB
testcase_08 AC 47 ms
11,008 KB
testcase_09 AC 175 ms
11,392 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 64 ms
11,264 KB
testcase_12 AC 265 ms
11,392 KB
testcase_13 AC 152 ms
11,392 KB
testcase_14 AC 355 ms
11,648 KB
testcase_15 AC 338 ms
11,648 KB
testcase_16 AC 315 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def sosu(N):
    nums = [n for n in range(2, N + 1)]
    i = 0
    while i <= len(nums) - 1:
        j = i + 1
        while j <= len(nums) - 1:
            if nums[j] % nums[i] == 0:
                nums.pop(j)
            else:
                j = j + 1
        i += 1
    return nums

def check(N):
    nums = [n for n in range(2, N + 1)]
    sosus = sosu(N)
    for i in range(len(nums)):
        if nums[i] != -1:
            for s in sosus:
                if i + s < N - 1:
                    nums[i + s] = -1
        else:
            continue
        if nums[-1] == -1:
            return 'Win'
    return 'Lose'

if __name__ == '__main__':
    N = int(input())
    print(check(N))
0