結果

問題 No.1791 Repeat Multiplication
ユーザー t98slidert98slider
提出日時 2023-07-29 04:22:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 3,000 ms
コード長 553 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 163,676 KB
実行使用メモリ 27,008 KB
最終ジャッジ日時 2024-04-16 11:45:07
合計ジャッジ時間 5,943 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
26,956 KB
testcase_01 AC 9 ms
26,880 KB
testcase_02 AC 9 ms
27,008 KB
testcase_03 AC 9 ms
26,992 KB
testcase_04 AC 9 ms
27,008 KB
testcase_05 AC 9 ms
26,852 KB
testcase_06 AC 10 ms
27,008 KB
testcase_07 AC 10 ms
26,860 KB
testcase_08 AC 28 ms
26,756 KB
testcase_09 AC 25 ms
26,880 KB
testcase_10 AC 26 ms
26,880 KB
testcase_11 AC 24 ms
26,960 KB
testcase_12 AC 17 ms
26,744 KB
testcase_13 AC 123 ms
26,752 KB
testcase_14 AC 130 ms
26,796 KB
testcase_15 AC 97 ms
26,880 KB
testcase_16 AC 95 ms
26,880 KB
testcase_17 AC 132 ms
26,880 KB
testcase_18 AC 107 ms
26,740 KB
testcase_19 AC 126 ms
26,880 KB
testcase_20 AC 100 ms
27,008 KB
testcase_21 AC 130 ms
26,880 KB
testcase_22 AC 144 ms
26,880 KB
testcase_23 AC 101 ms
26,868 KB
testcase_24 AC 124 ms
26,952 KB
testcase_25 AC 119 ms
26,880 KB
testcase_26 AC 125 ms
27,008 KB
testcase_27 AC 105 ms
26,880 KB
testcase_28 AC 137 ms
27,008 KB
testcase_29 AC 138 ms
26,824 KB
testcase_30 AC 138 ms
26,868 KB
testcase_31 AC 9 ms
26,920 KB
testcase_32 AC 136 ms
26,880 KB
testcase_33 AC 140 ms
26,824 KB
testcase_34 AC 129 ms
26,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int N, Q, x;
    cin >> N >> Q;
    array<long long, 1500001> dp, dp2;
    dp.fill(1);
    dp2.fill(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