結果

問題 No.303 割れません
ユーザー maine_honzuki
提出日時 2021-05-14 18:27:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 920 bytes
コンパイル時間 7,715 ms
コンパイル使用メモリ 399,096 KB
最終ジャッジ日時 2025-01-21 11:03:43
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 2 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/303/
#include <bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

cpp_int maine(int L) {
    cpp_int a = 1, b = 1, c = 1, d = 0, maine = 1, book = 1;
    if (L <= 2)
        return 1;
    L -= 2;
    while (L) {
        if (L & 1) {
            cpp_int tmp = a * maine + b * book;
            book = c * maine + d * book;
            maine = tmp;
        }
        cpp_int A, B, C, D;
        A = a * a + b * c;
        B = b * (a + d);
        C = c * (a + d);
        D = b * c + d * d;
        a = A;
        b = B;
        c = C;
        d = D;
        L >>= 1;
    }
    return maine;
}

int main() {
    int L;
    cin >> L;
    if (L == 2)
        cout << "INF" << endl
             << 0 << endl;
    else
        cout << L << endl
             << maine(L) - !(L & 1) * maine(L / 2) * maine(L / 2) << endl;
}
0