結果

問題 No.1791 Repeat Multiplication
ユーザー ripityripity
提出日時 2021-11-30 16:47:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 701 bytes
コンパイル時間 2,905 ms
コンパイル使用メモリ 201,040 KB
実行使用メモリ 29,140 KB
最終ジャッジ日時 2023-10-13 19:07:18
合計ジャッジ時間 8,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 233 ms
4,688 KB
testcase_09 AC 202 ms
4,448 KB
testcase_10 AC 199 ms
4,352 KB
testcase_11 AC 178 ms
4,352 KB
testcase_12 AC 100 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int main(void){
    int N,Q;
    cin >> N >> Q;
    vector<long> dp(N+1);
    vector<long> sum(N+1);
    dp[1] = sum[1] = 1;
    for( int i = 2; i <= N; i++ ) {
        dp[i] += dp[1];
        for( int j = 2; j*j <= i; j++ ) {
            if( i%j == 0 && j*j != i ) {
                dp[i] += dp[j]+dp[i/j];
            }else if( i%j == 0 ) {
                dp[i] += dp[j];
            }
        }
        sum[i] = dp[i]+sum[i-1];
    }
    for( int i = 0; i < Q; i++ ) {
        int x;
        cin >> x;
        printf("%ld\n",dp[x]*sum[N/x]);
    }
}
0