結果

問題 No.7 プライムナンバーゲーム
ユーザー pajannatpajannat
提出日時 2021-04-11 19:25:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,348 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 76,984 KB
最終ジャッジ日時 2023-09-09 21:29:16
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,196 KB
testcase_01 AC 71 ms
71,432 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 80 ms
75,916 KB
testcase_05 WA -
testcase_06 AC 132 ms
76,536 KB
testcase_07 AC 115 ms
76,752 KB
testcase_08 AC 97 ms
76,580 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 117 ms
76,864 KB
testcase_12 AC 199 ms
76,800 KB
testcase_13 AC 209 ms
76,672 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 220 ms
76,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import math
    from sys import stdin
    N = int(stdin.readline().rstrip())
    
    # 素数判定関数
    def isPrime(num):
        if num < 2:
            return False
        elif num == 2:
            return True
        elif num % 2 == 0:
            return False
        
        for i in range(3, math.floor(math.sqrt(num))+1, 2):
            if num % i == 0:
                return False
        
        # 上記以外の場合。素数。
        return True
    
    # 素数判定
    def callIsPrime(input_num=1000):
        numbers = []
        for i in range(1, input_num, 2):
            if isPrime(i):
                numbers.append(i)
        return numbers

    # Win/Loseリスト作成
    def MakeList(input_num):
        Prime_list = callIsPrime(input_num)
        Win_list = set()
        Lose_list = set()
        Lose_list.add(2)
        for i in range(3, input_num+1): #input_numは入力値
            for num in Prime_list:
                if num >= i:
                    break
                elif (i-num in Lose_list):
                    Win_list.add(i)
                else:
                    Lose_list.add(i)
        
        return Win_list
    
    Win_judge = MakeList(N)

    if N in Win_judge:
        print("Win")
    else:
        print("Lose")

if __name__ == '__main__':
    main()
0