結果

問題 No.1791 Repeat Multiplication
ユーザー t98slidert98slider
提出日時 2023-07-29 04:17:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 3,000 ms
コード長 550 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 164,592 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-16 11:39:17
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 20 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 17 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 141 ms
24,940 KB
testcase_14 AC 138 ms
25,344 KB
testcase_15 AC 96 ms
19,340 KB
testcase_16 AC 95 ms
19,048 KB
testcase_17 AC 142 ms
26,128 KB
testcase_18 AC 107 ms
21,540 KB
testcase_19 AC 135 ms
24,636 KB
testcase_20 AC 98 ms
20,096 KB
testcase_21 AC 129 ms
24,320 KB
testcase_22 AC 142 ms
26,308 KB
testcase_23 AC 99 ms
20,516 KB
testcase_24 AC 133 ms
25,224 KB
testcase_25 AC 114 ms
23,552 KB
testcase_26 AC 141 ms
25,696 KB
testcase_27 AC 107 ms
21,644 KB
testcase_28 AC 151 ms
26,624 KB
testcase_29 AC 141 ms
26,752 KB
testcase_30 AC 144 ms
26,752 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 152 ms
26,624 KB
testcase_33 AC 156 ms
26,736 KB
testcase_34 AC 145 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, 1);
    for(int i = N / 2; i >= 1; i--){
        for(int j = 2 * i; j <= N; j += i){
            dp[i] += dp[j];
        }
    }
    for(int i = 2, 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