結果

問題 No.1791 Repeat Multiplication
ユーザー yvay5cqeyvay5cqe
提出日時 2022-01-14 15:56:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 646 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 70,632 KB
最終ジャッジ日時 2023-08-12 09:16:58
合計ジャッジ時間 26,046 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
29,456 KB
testcase_01 AC 131 ms
29,732 KB
testcase_02 AC 129 ms
29,708 KB
testcase_03 AC 128 ms
29,668 KB
testcase_04 AC 129 ms
29,652 KB
testcase_05 AC 129 ms
29,600 KB
testcase_06 AC 129 ms
29,704 KB
testcase_07 AC 132 ms
29,680 KB
testcase_08 AC 561 ms
41,264 KB
testcase_09 AC 513 ms
40,012 KB
testcase_10 AC 509 ms
39,784 KB
testcase_11 AC 475 ms
38,772 KB
testcase_12 AC 328 ms
34,932 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 2,332 ms
56,628 KB
testcase_16 AC 2,234 ms
55,924 KB
testcase_17 TLE -
testcase_18 AC 2,730 ms
59,968 KB
testcase_19 TLE -
testcase_20 AC 2,470 ms
57,920 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 2,768 ms
58,348 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 AC 2,621 ms
59,892 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 AC 126 ms
29,832 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys
def input(): return sys.stdin.readline()


def main():
    N, Q = map(int, input().split())
    queries = [int(input()) for _ in range(Q)]

    dp = [0]*(N+1)
    dp[0] = dp[1] = 1
    for i in range(1, N+1):
        for j in range(i << 1, N+1, i):
            dp[j] += dp[i]

    dp = np.array(dp, dtype=np.int64)

    def calc(x):
        base = dp[x]  # x で終わるやつ
        ret = 0
        for y in range(1, N//x+1):
            ret += dp[y] * base

        return ret

    ans = []
    for x in queries:
        ans.append(str(calc(x)))
    print("\n".join(ans))


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