結果

問題 No.7 プライムナンバーゲーム
ユーザー pajannatpajannat
提出日時 2021-04-11 20:48:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,465 bytes
コンパイル時間 1,106 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 77,124 KB
最終ジャッジ日時 2023-09-09 22:40:23
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,068 KB
testcase_01 AC 72 ms
71,336 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 78 ms
76,084 KB
testcase_05 WA -
testcase_06 AC 96 ms
76,548 KB
testcase_07 AC 93 ms
76,632 KB
testcase_08 AC 87 ms
76,620 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 93 ms
76,760 KB
testcase_12 AC 115 ms
76,704 KB
testcase_13 AC 118 ms
76,808 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 121 ms
77,080 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)
        win_flg = False
        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_flg = True
                    break
            if win_flg:
                Win_list.add(i)
            else:
                Lose_list.add(i)
            win_flg = False

        return Win_list
    
    Win_judge = MakeList(N)

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

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