結果

問題 No.1791 Repeat Multiplication
ユーザー ace_amuro
提出日時 2023-04-13 18:08:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 106 ms / 3,000 ms
コード長 569 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 81,220 KB
実行使用メモリ 27,220 KB
最終ジャッジ日時 2024-10-09 15:47:16
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1.5e6+10;
int n,Q,x;
LL dp[MR],s[MR];
int main(){
    scanf("%d%d",&n,&Q);
    dp[1] = 1;
    for(int i=1;i<=n;i++) {
        for(int j=2*i;j<=n;j+=i){
            dp[j] += dp[i];
        }
        s[i] = s[i-1] + dp[i];
    }
    while(Q--){
        scanf("%d",&x);
        printf("%lld\n",dp[x]*s[n/x]);
    }
    return 0;
}
0