結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー lilictaka
提出日時 2022-09-26 23:28:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 68,912 KB
最終ジャッジ日時 2024-12-22 16:02:33
合計ジャッジ時間 6,788 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def erastotenes(n):
    is_prime = [True] *(n+1)
    is_prime[1] = False
    for p in range(2,n+1):
        if is_prime[p] == False:
            continue
        is_prime[p] = True
        k = 2
        while k * p < (n+1):
            is_prime[k*p] = False
            k +=1
    return is_prime
M = int(input())
if M == 0:
    M = 998244353
P = erastotenes(10 ** 5 + 1)
ans = []
for p in range(2,10**5+1):
    if P[p]:
        cnt =1
        while pow(p,cnt) <=10 ** 5 and pow(2,cnt) -1 <=M:
            ans.append(pow(p,cnt))
            cnt +=1
        M-=pow(2,cnt-1) -1

print(len(ans)) 
print(*ans)
0