結果
| 問題 | No.3776 Magic Square of Product |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-23 22:40:18 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 25 ms / 2,500 ms |
| + 993µs | |
| コード長 | 813 bytes |
| 記録 | |
| コンパイル時間 | 5,153 ms |
| コンパイル使用メモリ | 374,856 KB |
| 実行使用メモリ | 15,216 KB |
| 最終ジャッジ日時 | 2026-10-23 22:40:27 |
| 合計ジャッジ時間 | 8,308 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
constexpr array<ll,20> 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<ll> ans(th + 1, 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] *= 6;
}
}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] % 998244353 << '\n';
}
}