結果

問題 No.1791 Repeat Multiplication
ユーザー t98slidert98slider
提出日時 2023-07-29 04:12:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,459 ms / 3,000 ms
コード長 699 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 165,276 KB
実行使用メモリ 38,400 KB
最終ジャッジ日時 2024-04-16 11:34:53
合計ジャッジ時間 47,009 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 45 ms
6,944 KB
testcase_09 AC 39 ms
6,944 KB
testcase_10 AC 39 ms
6,940 KB
testcase_11 AC 35 ms
6,940 KB
testcase_12 AC 20 ms
6,944 KB
testcase_13 AC 2,141 ms
35,704 KB
testcase_14 AC 2,203 ms
36,608 KB
testcase_15 AC 1,205 ms
27,520 KB
testcase_16 AC 1,179 ms
26,880 KB
testcase_17 AC 2,328 ms
37,376 KB
testcase_18 AC 1,515 ms
30,848 KB
testcase_19 AC 2,027 ms
35,200 KB
testcase_20 AC 1,274 ms
28,544 KB
testcase_21 AC 2,003 ms
34,688 KB
testcase_22 AC 2,310 ms
37,504 KB
testcase_23 AC 1,387 ms
29,184 KB
testcase_24 AC 2,247 ms
36,224 KB
testcase_25 AC 1,911 ms
33,792 KB
testcase_26 AC 2,308 ms
36,864 KB
testcase_27 AC 1,601 ms
30,720 KB
testcase_28 AC 2,405 ms
38,400 KB
testcase_29 AC 2,415 ms
38,400 KB
testcase_30 AC 2,442 ms
38,400 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2,459 ms
38,400 KB
testcase_33 AC 2,387 ms
38,400 KB
testcase_34 AC 2,430 ms
38,272 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), dp3(N + 1);
    dp2[0] = 1;
    for(int i = N / 2; i >= 1; i--){
        for(int j = 2 * i; j <= N; j += i){
            dp[i] += dp[j];
        }
    }
    dp3[1] = 1;
    for(int j = __lg(N); j >= 0; j--){
        for(int i = N; i >= 1; i--){
            for(int j = 2 * i; j <= N; j += i){
                dp3[j] += dp3[i];
            }
            dp2[i] += dp3[i];
            dp3[i] = 0;
        }
    }
    while(Q--){
        cin >> x;
        cout << dp2[x] * dp[x] << '\n';
    }
}
0