結果

問題 No.1791 Repeat Multiplication
ユーザー t98slidert98slider
提出日時 2023-07-29 04:15:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 3,000 ms
コード長 563 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 165,428 KB
実行使用メモリ 26,724 KB
最終ジャッジ日時 2024-04-16 11:37:33
合計ジャッジ時間 6,507 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 21 ms
5,376 KB
testcase_09 AC 19 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 123 ms
24,832 KB
testcase_14 AC 133 ms
25,336 KB
testcase_15 AC 96 ms
19,332 KB
testcase_16 AC 97 ms
19,108 KB
testcase_17 AC 138 ms
25,956 KB
testcase_18 AC 116 ms
21,760 KB
testcase_19 AC 129 ms
24,568 KB
testcase_20 AC 104 ms
20,156 KB
testcase_21 AC 126 ms
24,264 KB
testcase_22 AC 137 ms
26,132 KB
testcase_23 AC 107 ms
20,352 KB
testcase_24 AC 126 ms
25,044 KB
testcase_25 AC 120 ms
23,572 KB
testcase_26 AC 135 ms
25,600 KB
testcase_27 AC 115 ms
21,632 KB
testcase_28 AC 137 ms
26,592 KB
testcase_29 AC 139 ms
26,624 KB
testcase_30 AC 140 ms
26,672 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 141 ms
26,624 KB
testcase_33 AC 144 ms
26,724 KB
testcase_34 AC 148 ms
26,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q, x;
    cin >> N >> Q;
    vector<ll> dp(N + 1, 1), dp2(N + 1);
    for(int i = N / 2; i >= 1; i--){
        for(int j = 2 * i; j <= N; j += i){
            dp[i] += dp[j];
        }
    }
    dp2[1] = 1;
    for(int i = 1, r = N / 2; i <= r; i++){
        for(int j = 2 * i; j <= N; j += i){
            dp2[j] += dp2[i];
        }
    }
    while(Q--){
        cin >> x;
        cout << dp2[x] * dp[x] << '\n';
    }
}
0