結果

問題 No.7 プライムナンバーゲーム
ユーザー kwnwsdnckwnwsdnc
提出日時 2018-03-30 23:51:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,164 ms / 5,000 ms
コード長 742 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 262,144 KB
最終ジャッジ日時 2024-04-09 04:28:09
合計ジャッジ時間 9,040 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
10,880 KB
testcase_01 AC 55 ms
10,752 KB
testcase_02 AC 1,164 ms
262,144 KB
testcase_03 AC 121 ms
24,832 KB
testcase_04 AC 71 ms
13,568 KB
testcase_05 AC 71 ms
13,568 KB
testcase_06 AC 375 ms
81,024 KB
testcase_07 AC 268 ms
57,216 KB
testcase_08 AC 146 ms
30,336 KB
testcase_09 AC 537 ms
119,296 KB
testcase_10 AC 56 ms
10,752 KB
testcase_11 AC 269 ms
57,600 KB
testcase_12 AC 829 ms
189,312 KB
testcase_13 AC 886 ms
200,960 KB
testcase_14 AC 1,144 ms
261,248 KB
testcase_15 AC 1,089 ms
248,448 KB
testcase_16 AC 1,010 ms
229,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
        
def minus(n):
    Q=[[] for i in range(n+10)]
    judge=[1 for i in range(n+10)]
    judge[2]=-1
    judge[3]=-1
    for i in range(2,n+1):
        count=0
        for p in prime:
            if i-p<=1:
                break
            else:
                Q[i].append(i-p)
        for q in Q[i]:
            if judge[q]==-1:
                count+=1
        if count==0:
            judge[i]=-1
    if judge[n]==-1:
        return "Lose"
    else:
        return "Win"
                
    
N=int(input())
print(minus(N))
0