結果

問題 No.2156 ぞい文字列
ユーザー hourenhouren
提出日時 2022-12-09 21:35:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,182 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 169,876 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 21:02:53
合計ジャッジ時間 2,845 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
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;}
constexpr ll INFLL = (1LL <<62), MOD = 998244353;
constexpr int INF = (1<<30);
template <typename T>
vector<vector<T>> MatrixProduct(vector<vector<T>> vec1, vector<vector<T>> vec2){
    int N = vec1.size(), M = vec2[0].size(), L = vec2.size();
    vector<vector<T>> res(N,vector<T>(M,0));
    rep(i,N) rep(j,M) rep(k,L) res[i][j] = (res[i][j] + vec1[i][k] * vec2[k][j]) % MOD;
    return res;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<vector<ll>> a(1,vector<ll>(2,0)), t(2,vector<ll>(2,0));
    a[0][0] = t[0][0] = t[0][1] = t[1][0] = 1;
    while(n){
        if(n&1) a = MatrixProduct(t,a);
        t = MatrixProduct(t,t);
        n >>= 1;
    }
    cout << (a[0][0]+a[0][1]-1+MOD) % MOD << '\n';
    return 0;
}
0