結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー tamatotamato
提出日時 2022-09-25 21:41:28
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,098 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 81,120 KB
最終ジャッジ日時 2023-08-24 02:06:35
合計ジャッジ時間 9,814 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,020 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 RE -
testcase_23 AC 81 ms
76,956 KB
testcase_24 AC 81 ms
76,864 KB
testcase_25 AC 81 ms
77,000 KB
testcase_26 AC 81 ms
76,968 KB
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    NMAX = 10 ** 5
    NMAX2 = 3 * 10 ** 2
    is_prime = [1] * (NMAX + 1)
    is_prime[0] = is_prime[1] = 0
    for p in range(2, NMAX + 1):
        if not is_prime[p]:
            continue
        for d in range(2, NMAX + 1):
            if p * d > NMAX:
                break
            is_prime[p * d] = 0

    prime_list = []
    for p in range(2, NMAX2 + 1):
        if is_prime[p]:
            prime_list.append(p)
    prime_list2 = []
    for p in range(NMAX2+1, NMAX):
        if is_prime[p]:
            prime_list2.append(p)

    ans = []
    M = int(input())
    i = 0
    for lv in range(30, 1, -1):
        k = 2 ** lv - 1
        if M >= k:
            M -= k
            p = prime_list[i]
            i += 1
            for _ in range(lv):
                ans.append(p * prime_list.pop())
        if M <= len(prime_list2):
            break
    for _ in range(M):
        p = prime_list[i]
        i += 1
        ans.append(p)

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


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