結果
| 問題 | No.3776 Magic Square of Product |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-23 23:36:16 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 232 ms / 2,500 ms |
| + 105µs | |
| コード長 | 3,701 bytes |
| 記録 | |
| コンパイル時間 | 6,600 ms |
| コンパイル使用メモリ | 285,344 KB |
| 実行使用メモリ | 9,920 KB |
| 最終ジャッジ日時 | 2026-10-23 23:36:36 |
| 合計ジャッジ時間 | 11,062 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
//python3 expander.py main.cpp
//export CPLUS_INCLUDE_PATH="/home/yantaro/kyopro/ac-library-master"
//https://github.com/yantaro-yanchan/kyopro-library/tree/master/library
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using lll = __int128_t;
using ulll = __uint128_t;
//using mint = modint; //mint::set_mod(M);
using mint = modint998244353;
//using mint = modint1000000007;
template<class T> using pq = priority_queue<T>; //大きい順
template<class T> using pq_g = priority_queue<T, vector<T>, greater<T>>; //小さい順
#define vec_unique(v) v.erase(unique(v.begin(), v.end()), v.end()) //重複削除
#define vec_iota(v) iota(v.begin(), v.end(), 0) //0, 1, 2, 3, ..., n - 1にセット
#define concat(a, b) a.insert(a.end(), b.begin(), b.end())
#define debug(x) cerr << #x << " = " << x << endl
#define maxvalue(array) *max_element(array.begin(), array.end())
#define minvalue(array) *min_element(array.begin(), array.end())
#define sumvalue(array) accumulate(array.begin(), array.end(), 0ll)
#define popcount(x) __builtin_popcountll(x)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> dist(1, N);
//dist(rng);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
#define INF 2e18
#define INF2 2e9
struct Eratosthenes {
vector<bool> isprime;
vector<int> minfactor;
void make(int n) {
isprime.resize(n + 1, true);
minfactor.resize(n + 1, -1);
isprime[1] = false;
minfactor[1] = 1;
for(int p = 2; p <= n; p++) {
if(!isprime[p]) continue;
minfactor[p] = p;
for(int q = p * 2; q <= n; q+=p) {
isprime[q] = false;
if(minfactor[q] == -1) minfactor[q] = p;
}
}
}
vector<pair<int, int>> factorize(int n) {
vector<pair<int, int>> res;
while(n > 1) {
int p = minfactor[n];
int exp = 0;
while(minfactor[n] == p) {
n /= p;
exp++;
}
res.push_back({p, exp});
}
return res;
}
};
const int N = 1e6 + 10;
Eratosthenes er;
vector<mint> cnt(21);
void solve() {
int k;
cin >> k;
auto res = er.factorize(k);
mint ans = 1;
for(auto[p, exp] : res) {
ans *= cnt[exp];
}
cout << ans.val() << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
er.make(N);
for(int i = 1; i <= 20; i++) {
mint res = 0;
vector<vector<int>> a(3, vector<int>(3));
auto dfs = [&](auto dfs, int k) -> void {
if(k == 4) {
a[0][2] = i - (a[0][0] + a[0][1]);
a[1][2] = i - (a[1][0] + a[1][1]);
a[2][0] = i - (a[0][0] + a[1][0]);
a[2][1] = i - (a[0][1] + a[1][1]);
if(a[0][2] < 0 || a[1][2] < 0 || a[2][0] < 0 || a[2][1] < 0) return;
if(a[0][2] + a[1][2] == a[2][0] + a[2][1]) {
a[2][2] = i - (a[0][2] + a[1][2]);
if(a[2][2] >= 0) cnt[i]++;
}
return;
}
int x = k / 2;
int y = k % 2;
for(int j = 0; j <= i; j++) {
a[x][y] = j;
dfs(dfs, k + 1);
}
};
dfs(dfs, 0);
}
int t;
cin >> t;
while(t--) {
solve();
}
//cout << fixed << setprecision(15) << << endl;
return 0;
}