結果
問題 | No.1791 Repeat Multiplication |
ユーザー |
|
提出日時 | 2022-01-14 15:56:04 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 646 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 107,064 KB |
最終ジャッジ日時 | 2024-11-19 08:47:50 |
合計ジャッジ時間 | 86,890 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 TLE * 18 |
ソースコード
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()