結果

問題 No.1791 Repeat Multiplication
ユーザー simansiman
提出日時 2023-05-03 11:23:32
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 3,000 ms
コード長 765 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 105,592 KB
実行使用メモリ 26,972 KB
最終ジャッジ日時 2023-08-13 22:59:10
合計ジャッジ時間 9,291 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
26,876 KB
testcase_01 AC 9 ms
26,808 KB
testcase_02 AC 8 ms
26,884 KB
testcase_03 AC 9 ms
26,808 KB
testcase_04 AC 9 ms
26,884 KB
testcase_05 AC 9 ms
26,904 KB
testcase_06 AC 9 ms
26,852 KB
testcase_07 AC 8 ms
26,864 KB
testcase_08 AC 168 ms
26,888 KB
testcase_09 AC 147 ms
26,876 KB
testcase_10 AC 145 ms
26,832 KB
testcase_11 AC 131 ms
26,900 KB
testcase_12 AC 85 ms
26,900 KB
testcase_13 AC 264 ms
26,880 KB
testcase_14 AC 267 ms
26,876 KB
testcase_15 AC 237 ms
26,948 KB
testcase_16 AC 234 ms
26,948 KB
testcase_17 AC 276 ms
26,876 KB
testcase_18 AC 249 ms
26,936 KB
testcase_19 AC 265 ms
26,876 KB
testcase_20 AC 237 ms
26,864 KB
testcase_21 AC 263 ms
26,968 KB
testcase_22 AC 274 ms
26,972 KB
testcase_23 AC 241 ms
26,880 KB
testcase_24 AC 267 ms
26,808 KB
testcase_25 AC 258 ms
26,944 KB
testcase_26 AC 270 ms
26,872 KB
testcase_27 AC 248 ms
26,880 KB
testcase_28 AC 275 ms
26,812 KB
testcase_29 AC 272 ms
26,784 KB
testcase_30 AC 275 ms
26,808 KB
testcase_31 AC 8 ms
26,908 KB
testcase_32 AC 271 ms
26,880 KB
testcase_33 AC 276 ms
26,940 KB
testcase_34 AC 277 ms
26,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

ll dp[1500010];
ll ans[1500010];

int main() {
  memset(dp, 0, sizeof(dp));
  memset(ans, 0, sizeof(ans));

  int N, Q;
  cin >> N >> Q;

  dp[1] = 1;
  for (int i = 1; i <= N; ++i) {
    if (dp[i] == 0) continue;

    int k = 2 * i;
    while (k <= N) {
      dp[k] += dp[i];
      k += i;
    }
  }

  for (int i = 1; i <= N; ++i) {
    for (int k = 1; k <= N / i; ++k) {
      ans[i] += dp[i] * dp[k];
    }
  }

  for (int t = 0; t < Q; ++t) {
    int x;
    cin >> x;

    cout << ans[x] << endl;
  }

  return 0;
}
0