結果

問題 No.64 XORフィボナッチ数列
ユーザー jimanojimano
提出日時 2018-02-04 16:07:42
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 803 bytes
コンパイル時間 3,165 ms
コンパイル使用メモリ 71,300 KB
実行使用メモリ 54,416 KB
最終ジャッジ日時 2023-09-12 16:02:04
合計ジャッジ時間 10,295 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,760 KB
testcase_01 AC 41 ms
49,304 KB
testcase_02 AC 41 ms
49,324 KB
testcase_03 AC 41 ms
49,600 KB
testcase_04 AC 42 ms
49,196 KB
testcase_05 AC 42 ms
49,200 KB
testcase_06 AC 42 ms
49,416 KB
testcase_07 AC 43 ms
49,196 KB
testcase_08 AC 42 ms
49,328 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1_5;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No0064 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] str = br.readLine().split(" ");
			long f0 = Long.parseLong(str[0]);
			long f1 = Long.parseLong(str[1]);
			long n = Long.parseLong(str[2]);

			System.out.println(xor(f1, f0, n));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static long xor(long f1, long f0, long n) {

		if (n == 0) {
			return f0;
		} else if (n == 1) {
			return f1;
		}

		long fk1 = f1;
		long fk2 = f0;
		long fk = fk1 ^ fk2;
		for (long i = 0; i < n - 2; i++) {
			fk2 = fk1;
			fk1 = fk;
			fk = fk1 ^ fk2;
		}
		return fk;
	}
}
0