結果

問題 No.303 割れません
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-14 18:27:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 920 bytes
コンパイル時間 11,572 ms
コンパイル使用メモリ 435,520 KB
実行使用メモリ 6,684 KB
最終ジャッジ日時 2023-07-25 03:47:11
合計ジャッジ時間 28,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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