結果

問題 No.1791 Repeat Multiplication
ユーザー HIcoderHIcoder
提出日時 2023-07-12 11:25:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 3,000 ms
コード長 853 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 101,880 KB
実行使用メモリ 27,252 KB
最終ジャッジ日時 2023-10-12 01:35:59
合計ジャッジ時間 9,194 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 157 ms
4,956 KB
testcase_09 AC 139 ms
4,696 KB
testcase_10 AC 139 ms
4,680 KB
testcase_11 AC 124 ms
4,628 KB
testcase_12 AC 74 ms
4,352 KB
testcase_13 AC 257 ms
25,256 KB
testcase_14 AC 261 ms
25,516 KB
testcase_15 AC 233 ms
19,588 KB
testcase_16 AC 231 ms
19,372 KB
testcase_17 AC 266 ms
26,308 KB
testcase_18 AC 253 ms
21,972 KB
testcase_19 AC 264 ms
24,924 KB
testcase_20 AC 237 ms
20,252 KB
testcase_21 AC 257 ms
24,476 KB
testcase_22 AC 274 ms
26,448 KB
testcase_23 AC 237 ms
20,660 KB
testcase_24 AC 263 ms
25,420 KB
testcase_25 AC 249 ms
23,904 KB
testcase_26 AC 274 ms
25,728 KB
testcase_27 AC 247 ms
21,956 KB
testcase_28 AC 278 ms
27,036 KB
testcase_29 AC 282 ms
27,252 KB
testcase_30 AC 271 ms
26,848 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 283 ms
27,052 KB
testcase_33 AC 269 ms
26,916 KB
testcase_34 AC 268 ms
26,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);


int main(){
    int N,Q;
    cin>>N>>Q;
    vector<int> x(Q);
    for(int q=0;q<Q;q++){
        cin>>x[q];
    }

    vector<ll> dp(N+1,0);
    dp[1]=1;//末尾が1である者は最初の1とおり
    
    for(int a=1;a<=N;a++){
        for(int b=2*a;b<=N;b+=a){
            dp[b]+=dp[a];
        }
    }

    vector<ll> ans(N+1);
    
    for(int i=1;i<=N;i++){
        
        for(ll k=1;i*k<=N;k++){
            ans[i]+=dp[k]*dp[i];
        }
    }

    for(int q=0;q<Q;q++){
        cout<<ans[x[q]]<<endl;
    }


}
0