結果
| 問題 |
No.1791 Repeat Multiplication
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-12-20 06:24:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 314 ms / 3,000 ms |
| コード長 | 571 bytes |
| コンパイル時間 | 3,681 ms |
| コンパイル使用メモリ | 251,144 KB |
| 最終ジャッジ日時 | 2025-01-27 04:12:16 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 100000000000000
long long suf[2000000],pre[2000000];
int main(){
int N,Q;
cin>>N>>Q;
suf[1] = 1;
for(int i=1;i<=N;i++){
for(int j=i*2;j<=N;j+=i){
suf[j] += suf[i];
}
}
for(int i=N;i>=1;i--){
pre[i] = 1;
for(int j=i*2;j<=N;j+=i)pre[i] += pre[j];
}
rep(_,Q){
int x;
cin>>x;
long long ans = suf[x] * pre[x];
cout<<ans<<endl;
}
return 0;
}
沙耶花