結果
| 問題 | No.1791 Repeat Multiplication |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-12 11:25:16 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 3,000 ms |
| コード長 | 853 bytes |
| 記録 | |
| コンパイル時間 | 650 ms |
| コンパイル使用メモリ | 116,756 KB |
| 実行使用メモリ | 27,264 KB |
| 最終ジャッジ日時 | 2026-07-01 18:26:53 |
| 合計ジャッジ時間 | 5,935 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#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;
}
}