結果

問題 No.2156 ぞい文字列
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-12-09 22:01:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,563 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 193,152 KB
実行使用メモリ 17,088 KB
最終ジャッジ日時 2024-04-22 22:08:37
合計ジャッジ時間 8,161 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll const m = 998244353;
int main () {
    ll N;
    cin >> N;
    N --;
    ll mat[2][2];
    mat[0][0] = 0;
    mat[0][1] = mat[1][1] = mat[1][0] = 1;
    ll ret[2][2];
    for (int i = 0; i < 2; i ++) {
        for (int j = 0; j < 2; j ++) {
            ret[i][j] = (i == j);
        }
    }
    while (N) {
        if (N & 1) {
            ll mat2[2][2];
            for (int i = 0; i < 4; i ++) {
                mat2[i >> 1][i & 1] = 0;
            }
            for (int i = 0; i < 2; i ++) {
                for (int j = 0; j < 2; j ++) {
                    for (int k = 0; k < 2; k ++) {
                        mat2[i][j] += ret[i][k] * mat[k][j];
                    }
                    mat2[i][j] %= m;
                }
            }
            for (int i = 0; i < 4; i ++) {
                ret[i >> 1][i & 1] = mat2[i >> 1][i & 1];
            }
        }
        N >> 1;
        ll mat2[2][2];
        for (int i = 0; i < 4; i ++) {
            mat2[i >> 1][i & 1] = 0;
        }
        for (int i = 0; i < 2; i ++) {
            for (int j = 0; j < 2; j ++) {
                for (int k = 0; k < 2; k ++) {
                    mat2[i][j] += mat[i][k] * mat[k][j];
                }
                mat2[i][j] %= m;
            }
        }
        for (int i = 0; i < 4; i ++) {
            mat[i >> 1][i & 1] = mat2[i >> 1][i & 1];
        }
    }
    return 0;
    ll ans = ret[0][0] + ret[0][1] * 2;
    ans %= m;
    ans += m - 1;
    ans %= m;
    cout << ans << endl;
}
0