結果

問題 No.2156 ぞい文字列
ユーザー 👑 potato167potato167
提出日時 2022-12-10 00:29:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 201,468 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 23:28:10
合計ジャッジ時間 2,688 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
}
0