結果

問題 No.1791 Repeat Multiplication
ユーザー 沙耶花沙耶花
提出日時 2021-12-20 06:24:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 320 ms / 3,000 ms
コード長 571 bytes
コンパイル時間 5,436 ms
コンパイル使用メモリ 258,000 KB
実行使用メモリ 28,176 KB
最終ジャッジ日時 2023-10-13 19:25:59
合計ジャッジ時間 14,053 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,400 KB
testcase_01 AC 2 ms
5,436 KB
testcase_02 AC 1 ms
5,472 KB
testcase_03 AC 2 ms
5,612 KB
testcase_04 AC 3 ms
5,480 KB
testcase_05 AC 3 ms
5,620 KB
testcase_06 AC 2 ms
5,576 KB
testcase_07 AC 2 ms
5,524 KB
testcase_08 AC 155 ms
8,276 KB
testcase_09 AC 139 ms
6,168 KB
testcase_10 AC 132 ms
6,108 KB
testcase_11 AC 121 ms
6,012 KB
testcase_12 AC 72 ms
5,912 KB
testcase_13 AC 290 ms
28,176 KB
testcase_14 AC 299 ms
25,636 KB
testcase_15 AC 248 ms
19,808 KB
testcase_16 AC 247 ms
19,492 KB
testcase_17 AC 308 ms
26,280 KB
testcase_18 AC 268 ms
21,900 KB
testcase_19 AC 296 ms
24,696 KB
testcase_20 AC 280 ms
20,344 KB
testcase_21 AC 293 ms
24,796 KB
testcase_22 AC 309 ms
26,380 KB
testcase_23 AC 261 ms
20,868 KB
testcase_24 AC 293 ms
25,408 KB
testcase_25 AC 285 ms
23,648 KB
testcase_26 AC 299 ms
25,796 KB
testcase_27 AC 268 ms
21,740 KB
testcase_28 AC 306 ms
26,796 KB
testcase_29 AC 305 ms
27,140 KB
testcase_30 AC 320 ms
26,800 KB
testcase_31 AC 2 ms
4,968 KB
testcase_32 AC 310 ms
26,940 KB
testcase_33 AC 311 ms
27,016 KB
testcase_34 AC 311 ms
27,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0