結果

問題 No.64 XORフィボナッチ数列
ユーザー nanaenanae
提出日時 2017-01-02 06:19:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 10,512 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2023-08-22 07:34:19
合計ジャッジ時間 1,255 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,764 KB
testcase_01 AC 15 ms
7,820 KB
testcase_02 WA -
testcase_03 AC 15 ms
7,864 KB
testcase_04 AC 15 ms
7,936 KB
testcase_05 AC 15 ms
7,836 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 15 ms
7,844 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 15 ms
7,796 KB
testcase_12 AC 16 ms
7,928 KB
testcase_13 AC 15 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# yukicoder No.64 XORフィボナッチ数列

'''
状態遷移は
f_2 = f_0 ^ f_1 とすると
f_0, f_1, f_2, f_1, f_0, f_2, f_0, f_1, f_2, f_1, ...
となるので、indexを3で割った余りと商の偶奇が分かれば求まる
'''

def fib_xor(f_0, f_1, n):
    f = [f_0, f_1, f_0 ^ f_1]
    
    if n % 3 == 2:
        return f[2]
    elif (n // 3) % 2 == 0:
        return f[n % 3]
    else:
        return f[1 - (n % 3)]
        
f_0, f_1, n = map(int, input().split())
print(fib_xor(f_0, f_1, n))
0