結果

問題 No.7 プライムナンバーゲーム
ユーザー kwnwsdnckwnwsdnc
提出日時 2018-03-30 18:56:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 76,064 KB
最終ジャッジ日時 2023-09-08 07:27:04
合計ジャッジ時間 5,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
8,456 KB
testcase_01 AC 29 ms
8,500 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 352 ms
75,328 KB
testcase_05 WA -
testcase_06 AC 345 ms
76,064 KB
testcase_07 AC 346 ms
75,596 KB
testcase_08 AC 189 ms
41,816 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 343 ms
75,572 KB
testcase_12 AC 343 ms
75,436 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 346 ms
75,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def game(N):
    prime=[]
    for i in range(2,10000):
        judge=0
        for j in range(2,100):
            if i==j:
                break
            if i%j==0 :
                judge+=1
                break
        if judge==0:
            prime.append(i)


    Q=[[0]]
    have=[0 for i in range(20000)]
    for i in range(10000):
        for q in Q[i]:
            Q.append([])
            for p in prime:
                if  p+q>10000:
                    break
                if have[q+p]==0:
                    Q[i+1].append(q+p)
                    if p+q==N:
                        if i%2==0:
                            return "Win"
                        else:
                            return"Lose"

N=int(input())
print(game(N))
                
    
0