結果

問題 No.64 XORフィボナッチ数列
ユーザー LeonardoneLeonardone
提出日時 2015-10-14 17:08:30
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 561 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 11,428 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-09-28 13:07:21
合計ジャッジ時間 2,169 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,184 KB
testcase_01 AC 82 ms
15,356 KB
testcase_02 AC 83 ms
15,160 KB
testcase_03 AC 82 ms
15,288 KB
testcase_04 AC 82 ms
15,148 KB
testcase_05 AC 84 ms
15,116 KB
testcase_06 AC 82 ms
15,228 KB
testcase_07 AC 83 ms
15,212 KB
testcase_08 AC 80 ms
15,140 KB
testcase_09 AC 82 ms
15,256 KB
testcase_10 AC 82 ms
15,204 KB
testcase_11 AC 81 ms
15,232 KB
testcase_12 AC 83 ms
15,164 KB
testcase_13 AC 82 ms
15,152 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU

F0, F1, N = gets.chomp.split.map(&:to_i)

# 頭の中を整理するためメモ


# Fk = Fk-1 XOR Fk-2

# F2 = F1 XOR F0
# F3 = F2 XOR F1 == F0 (F0とF1のXORにF1をXORするのだからF0になるだけ
# F4 = F3 XOR F2 == F1 (F3==F0なのでF0とF1をXORしたF2とXORしたらF1になるだけ
# F5 = F4 XOR F3 == F1 XOR F0 == F2 (もうこれを順々繰り返すだけ

# つまり [F0, F1, F0 XOR F1][N % 3] でおk

case N % 3
when 0
	puts F0
when 1
	puts F1
else
	puts (F0 ^ F1)
end
0