結果

問題 No.1791 Repeat Multiplication
ユーザー simansiman
提出日時 2023-05-03 11:22:04
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 765 bytes
コンパイル時間 6,659 ms
コンパイル使用メモリ 103,712 KB
実行使用メモリ 19,160 KB
最終ジャッジ日時 2023-08-13 22:58:38
合計ジャッジ時間 12,974 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
18,996 KB
testcase_01 AC 6 ms
19,112 KB
testcase_02 AC 7 ms
19,044 KB
testcase_03 AC 7 ms
18,996 KB
testcase_04 AC 7 ms
19,020 KB
testcase_05 AC 8 ms
19,148 KB
testcase_06 AC 6 ms
19,072 KB
testcase_07 AC 7 ms
19,160 KB
testcase_08 AC 171 ms
19,040 KB
testcase_09 AC 149 ms
19,072 KB
testcase_10 AC 147 ms
19,068 KB
testcase_11 AC 136 ms
19,068 KB
testcase_12 AC 83 ms
19,136 KB
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 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 7 ms
19,076 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

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[1000010];
ll ans[1000010];

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