結果

問題 No.1791 Repeat Multiplication
コンテスト
ユーザー ygussany
提出日時 2021-12-20 00:08:34
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
TLE  
実行時間 -
コード長 510 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 191 ms
コンパイル使用メモリ 38,880 KB
最終ジャッジ日時 2026-02-22 08:40:20
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 TLE * 10 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

int main()
{
	int i, N, Q;
	long long ans[2][1500001];
	scanf("%d %d", &N, &Q);
	
	int j;
	for (i = N; i >= 1; i--) for (j = 2, ans[0][i] = 1; i * j <= N; j++) ans[0][i] += ans[0][i*j];
	for (i = 1; i <= N; i++) {
		for (j = 2, ans[1][i] = 1; j * j < i; j++) if (i % j == 0) ans[1][i] += ans[1][j] + ans[1][i/j];
		if (j * j == i) ans[1][i] += ans[1][j];
	}
	
	int x;
	for (i = 1; i <= Q; i++) {
		scanf("%d", &x);
		printf("%lld\n", ans[0][x] * ans[1][x]);
	}
	fflush(stdout);
	return 0;
}
0