結果

問題 No.3776 Magic Square of Product
コンテスト
ユーザー t98slider
提出日時 2026-10-23 22:37:49
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 25 ms / 2,500 ms
+ 810µs
コード長 853 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,214 ms
コンパイル使用メモリ 380,576 KB
実行使用メモリ 11,316 KB
最終ジャッジ日時 2026-10-23 22:37:57
合計ジャッジ時間 7,251 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<mint> dp = {0,6,21,55,120,231,406,666,1035,1540,2211,3081,4186,5565,7260,9316,11781,14706,18145,22155};
	constexpr int th = 1'000'000;
	vector<int> cnt(th + 1);
	vector<mint> ans(th + 1, mint::raw(1));
	for(int i = 2; i <= th; i++){
		if(cnt[i]) continue;
		if(i > 1000){
			for(int j = i; j <= th; j += i){
				cnt[j] = 1;
				ans[j] *= dp[1];
			}
		}else{
			for(int j = i; j <= th; j += i) cnt[j] = 1;
			int v = i * i;
			while(v <= th){
				for(int j = v; j <= th; j += v) cnt[j]++;
				v *= i;
			}
			for(int j = i; j <= th; j += i) ans[j] *= dp[cnt[j]];
		}
	}
	int T;
	cin >> T;
	while(T--){
		int v;
		cin >> v;
		cout << ans[v].val() << '\n';
	}
}
0