結果

問題 No.64 XORフィボナッチ数列
ユーザー pro_kunipro_kuni
提出日時 2019-09-19 16:54:58
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 505 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 143,052 KB
実行使用メモリ 7,856 KB
最終ジャッジ日時 2023-09-26 14:01:04
合計ジャッジ時間 8,221 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
    unsigned long f0, f1, n;
    std::cin >> f0 >> f1 >> n;
    if (n == 0) {
        std::cout << f0 << std::endl;
    } else if (n == 1) {
        std::cout << f1 << std::endl;
    } else {
        unsigned long fi, fi_1, fi_2;
        fi_1 = f1;
        fi_2 = f0;
        for (unsigned long i = 2; i <= n; i++) {
            fi = fi_1 ^ fi_2;
            fi_2 = fi_1;
            fi_1 = fi;
        }
        std::cout << fi << std::endl;
    }

    return 0;
}
0