結果
| 問題 | No.3776 Magic Square of Product |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-28 12:46:49 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 19 ms / 2,500 ms |
| + 972µs | |
| コード長 | 1,028 bytes |
| 記録 | |
| コンパイル時間 | 2,205 ms |
| コンパイル使用メモリ | 333,020 KB |
| 実行使用メモリ | 9,852 KB |
| 最終ジャッジ日時 | 2026-10-28 12:47:02 |
| 合計ジャッジ時間 | 6,415 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;
const int MAX = 1000000;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
// 最小素因数を前計算
vector<int> spf(MAX + 1);
for (int i = 2; i <= MAX; i++) {
if (spf[i] != 0) continue;
spf[i] = i;
if (1LL * i * i > MAX) continue;
for (int j = i * i; j <= MAX; j += i) {
if (spf[j] == 0) spf[j] = i;
}
}
// 指数 e に対応する場合の数
auto cal = [&](ll e) -> ll {
return (e + 1) * (e + 2)
* (e * e + 3 * e + 4) / 8;
};
int T;
cin >> T;
while (T--) {
int K;
cin >> K;
ll ans = 1;
while (K > 1) {
int p = spf[K];
int e = 0;
while (K % p == 0) {
K /= p;
e++;
}
ans = ans * cal(e) % MOD;
}
cout << ans << '\n';
}
return 0;
}