結果

問題 No.64 XORフィボナッチ数列
ユーザー dazydazy
提出日時 2016-09-09 01:00:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 3,486 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 54,428 KB
最終ジャッジ日時 2024-04-27 18:22:57
合計ジャッジ時間 5,261 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
53,860 KB
testcase_01 AC 116 ms
53,812 KB
testcase_02 AC 116 ms
53,140 KB
testcase_03 AC 146 ms
54,428 KB
testcase_04 AC 110 ms
54,120 KB
testcase_05 AC 100 ms
53,352 KB
testcase_06 AC 105 ms
53,056 KB
testcase_07 AC 110 ms
54,084 KB
testcase_08 AC 110 ms
53,800 KB
testcase_09 AC 109 ms
53,884 KB
testcase_10 AC 103 ms
52,968 KB
testcase_11 AC 101 ms
52,804 KB
testcase_12 AC 116 ms
54,252 KB
testcase_13 AC 99 ms
53,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        long[] F = new long[3];
        F[0] = scan.nextLong();
        F[1] = scan.nextLong();
        long N = scan.nextLong();
        if (F[0] < 0||F[1] < 0||N > Math.pow(10d, 18)) System.exit(1);

        if (N==0) {
            System.out.println(F[0]);
            System.exit(0);
        } else {
            F[2] = F[0] ^ F[1];
            F[0] = F[1];
            F[1] = F[2];
            F[2] = F[0] ^ F[1];
            System.out.println(F[((int) ((N - 1) % 3L))]);
        }
    }
}
0