結果

問題 No.7 プライムナンバーゲーム
ユーザー DialBirdDialBird
提出日時 2017-03-12 14:43:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 216 ms / 5,000 ms
コード長 767 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-09 04:11:22
合計ジャッジ時間 2,628 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 214 ms
11,648 KB
testcase_03 AC 41 ms
11,264 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 87 ms
11,008 KB
testcase_07 AC 69 ms
11,136 KB
testcase_08 AC 48 ms
11,136 KB
testcase_09 AC 116 ms
11,520 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 69 ms
11,136 KB
testcase_12 AC 167 ms
11,520 KB
testcase_13 AC 172 ms
11,648 KB
testcase_14 AC 216 ms
11,648 KB
testcase_15 AC 205 ms
11,648 KB
testcase_16 AC 190 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

class Yukicoder:
    def __init__(self):
        self.n = int(input())

    def run(self):
        dp = set([0,1])
        primes = set([])
        for i in range(2, self.n + 1):
            if self.prime_check(i):
                primes.add(i)
            for j in primes:
                if (i - j) not in dp:
                    dp.add(i)
                    break
        if self.n in dp:
            return "Win"
        else:
            return "Lose"

    
    def prime_check(self, n):
        if n < 2:
            return False
        else:
            i = 2
            while i <= sqrt(n):
                if n % i == 0:
                    return False
                i += 1
            return True


y = Yukicoder()
print(y.run())
0