結果
問題 |
No.2156 ぞい文字列
|
ユーザー |
👑 ![]() |
提出日時 | 2022-12-10 00:29:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 747 bytes |
コンパイル時間 | 1,907 ms |
コンパイル使用メモリ | 198,244 KB |
最終ジャッジ日時 | 2025-02-09 08:59:15 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) using ll = long long; template<class T> bool chmin(T &a,const T b){if(a>b){a=b;return 1;}return 0;} template<class T> bool chmax(T &a,const T b){if(a<b){a=b;return 1;}return 0;} const int INF = (1<<30)-1; const int mod=998244353; #define all(p) p.begin(),p.end() int main(){ ll N; cin>>N; vector<vector<ll>> base={{1,1},{1,0}}; ll A=0,B=1; while(N){ if(N&1){ ll C=(A*base[0][0]+B*base[1][0])%mod; ll D=(A*base[0][1]+B*base[1][1])%mod; A=C,B=D; } N/=2; vector<vector<ll>> tmp(2,vector<ll>(2)); rep(i,0,2) rep(j,0,2) rep(k,0,2){ tmp[i][j]=(tmp[i][j]+(base[i][k]*base[k][j]))%mod; } swap(tmp,base); } cout<<(A+B+mod-1)%mod<<"\n"; }