結果

問題 No.7 プライムナンバーゲーム
ユーザー lllllll88938494lllllll88938494
提出日時 2023-05-07 12:38:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 624 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 76,752 KB
最終ジャッジ日時 2023-08-16 03:28:22
合計ジャッジ時間 3,746 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,244 KB
testcase_01 AC 75 ms
76,068 KB
testcase_02 AC 85 ms
76,448 KB
testcase_03 AC 79 ms
76,368 KB
testcase_04 AC 78 ms
76,428 KB
testcase_05 AC 76 ms
76,416 KB
testcase_06 AC 82 ms
76,476 KB
testcase_07 AC 79 ms
76,752 KB
testcase_08 AC 79 ms
76,388 KB
testcase_09 AC 83 ms
76,248 KB
testcase_10 AC 74 ms
75,996 KB
testcase_11 AC 80 ms
76,432 KB
testcase_12 AC 85 ms
76,412 KB
testcase_13 AC 88 ms
76,444 KB
testcase_14 AC 89 ms
76,616 KB
testcase_15 AC 87 ms
76,452 KB
testcase_16 AC 87 ms
76,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def  c(n):
    sosu=[True]*(n+1)
    sosu[0],sosu[1] = False,False
    cnt=0
    for i in range(4,n+1,2):
        sosu[i] = False
    
    for i in range(3,int(n**0.5)+1,2):
        if sosu[i] == False:
            continue
        for j in range(i,n//i+1,2):
            sosu[j*i]=False
    return [p for p in range(n + 1) if sosu[p]==True]
    
p=c(10**4)

n=int(input())
#先攻自分

d = [0]*(n+1)
d[0] = 1
d[1] = 1

for i in range(2,n+1):
    f = 0
    for j in p:
        if i-j < 0:
            break
        if d[i-j] == 0:
            f = 1
            break
    d[i] = f
    
print('Lose' if d[n] == 0 else 'Win')
0