結果

問題 No.7 プライムナンバーゲーム
ユーザー pajannatpajannat
提出日時 2021-04-11 20:45:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,515 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 81,136 KB
最終ジャッジ日時 2023-09-09 22:37:44
合計ジャッジ時間 7,163 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = []
        Lose_list = [2]
    #    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.append(i)
            else:
                Lose_list.append(i)
            win_flg = False
        print(Win_list)
        print(Lose_list)
        return Win_list
    
    Win_judge = MakeList(N)

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

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