結果

問題 No.64 XORフィボナッチ数列
ユーザー @abcde@abcde
提出日時 2019-02-16 03:07:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 925 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 159,620 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 03:53:27
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
    
    // 1. 入力情報取得.
    LL F0, F1, N;
    cin >> F0 >> F1 >> N;
    
    // 2. XORフィボナッチ数列を計算.
    // ex. 88 79 2 なら, 
    // F0, F1, F2, ... は, 88, 79, 23, 88, 79, 23, 88, 79, ... の繰り返しになっている.
    // -> よって, N を 3で割ったときの余りが0なら, F0, 余りが1ならF1, 余りが2ならF2 に等しいことが分かる.
    // LL F2 = F0 ^ F1;
    // LL F3 = F1 ^ F2;
    // LL F4 = F2 ^ F3;
    // LL F5 = F3 ^ F4;
    // LL F6 = F4 ^ F5;
    // LL F7 = F5 ^ F6;
    // cout << F2 << " " << F3 << " " << F4 << " " << F5 << " " << F6 << " " << F7;
    LL remainder = N % 3;
    LL ans = 0;
    if(remainder == 0) ans = F0;
    if(remainder == 1) ans = F1;
    if(remainder == 2) ans = F0 ^ F1;
    
    // 3. 出力.
    cout << ans << endl;
    return 0;
    
}
0