結果

問題 No.3776 Magic Square of Product
コンテスト
ユーザー hiro1729
提出日時 2026-10-23 21:33:30
言語 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  
実行時間 52 ms / 2,500 ms
+ 775µs
コード長 835 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,564 ms
コンパイル使用メモリ 336,696 KB
実行使用メモリ 19,056 KB
最終ジャッジ日時 2026-10-23 21:33:38
合計ジャッジ時間 6,396 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	vector<int> C(21);
	for (int i = 1; i < 21; i++) {
		for (int a = 0; a <= i; a++) {
			for (int b = 0; b <= i - a; b++) {
				for (int c = 0; c <= i; c++) {
					for (int d = 0; d <= i - c; d++) {
						if (a + c <= i && b + d <= i && i <= a + b + c + d) {
							C[i]++;
						}
					}
				}
			}
		}
	}
	vector<ll> ans(1e6 + 1, 1);
	vector<ll> M(1e6 + 1); iota(M.begin(), M.end(), 0);
	for (int i = 2; i <= 1e6; i++) {
		if (M[i] == i) {
			for (int j = i; j <= 1e6; j += i) {
				int e = 0;
				while (M[j] % i == 0) {
					e++; M[j] /= i;
				}
				ans[j] = ans[j] * C[e] % mod;
			}
		}
	}
	int T; cin >> T;
	while (T--) {
		int K; cin >> K;
		cout << ans[K] << '\n';
	}
}
0