結果
問題 |
No.3243 Multiplication 8 1
|
ユーザー |
![]() |
提出日時 | 2025-08-22 21:17:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 2,198 bytes |
コンパイル時間 | 4,612 ms |
コンパイル使用メモリ | 266,364 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-22 21:17:45 |
合計ジャッジ時間 | 4,285 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
/** author: shobonvip created: 2025.08.22 21:08:58 **/ #include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); vector mat(60, vector(10, vector<mint>(10))); vector<ll> tar = {1,-1,2,-2,4,-4,8,-8,1,-1}; vector<ll> koho = {1,-1,2,-2}; map<ll,int> taio; rep(i,0,8){ taio[tar[i]]=i; } rep(i,0,10) { rep(j,0,4) { if (abs(tar[i] * koho[j]) > 8 || (tar[i]*koho[j]==-8 && tar[i]==8)) { if (tar[i]==8) { mat[0][taio[koho[j]]][i] += 1; } }else{ if(i>=8&&abs(koho[j])==1){ if(koho[j]*tar[i]==-1){ mat[0][9][i] += 1; }else{ mat[0][8][i] += 1; } }else{ mat[0][taio[koho[j]*tar[i]]][i] += 1; } } } } rep(num,0,59){ rep(i,0,10){ rep(j,0,10){ rep(k,0,10){ mat[num+1][i][j]+=mat[num][i][k]*mat[num][k][j]; } } } } int t; cin >> t; while(t--){ ll n; cin >> n; vector<mint> ans(10); ans[8] = 1; rep(num,0,60){ if(n>>num&1){ vector<mint> nans(10); rep(i,0,10){ rep(j,0,10){ nans[i]+=mat[num][i][j]*ans[j]; } } swap(nans,ans); } } cout<<(ans[6]+ans[0]).val()<<'\n'; } }