結果

問題 No.3776 Magic Square of Product
コンテスト
ユーザー aogera
提出日時 2026-08-11 21:48:58
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 605 ms / 2,500 ms
+ 153µs
コード長 773 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,348 ms
コンパイル使用メモリ 337,652 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2026-10-23 20:53:20
合計ジャッジ時間 15,084 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/modint>
using mint=atcoder::modint998244353;
int main(){

  constexpr int B=20;
  vector<int> cnt(B);
  for(int s=0;s<B;s++){
    for(int a=0;a<=s;a++) for(int b=0;b<=s;b++) for(int d=0;d<=s;d++) for(int e=0;e<=s;e++){
      // |a|b|c|
      // |d|e|f|
      // |h|i|j|
      int c=s-a-b;int f=s-d-e;int h=s-a-d;int i=s-b-e;
      if(c+f!=h+i) continue;
      int j=s-c-f;
      if(c>=0&&f>=0&&h>=0&&i>=0&&j>=0){
        cnt[s]++;
      }
    }
  }

  int T;cin>>T;
  while(T--){
    int K;cin>>K;
    int now=K;
    mint ans=1;
    for(int p=2;p*p<=K;p++){
      int c=0;
      while(now%p==0){
        now/=p;c++;
      }
      ans *= cnt[c];
    }
    if(now>1) ans*=cnt[1];
    cout<<ans.val()<<endl;
  }
}
0