結果

問題 No.64 XORフィボナッチ数列
ユーザー masa
提出日時 2015-02-12 20:36:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 477 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 59,780 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 19:17:12
合計ジャッジ時間 1,074 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const long long pattern[4][3] = {
	{0, 0, 0},
	{0, 1, 1},
	{1, 0, 1},
	{1, 1, 0}
};

int main() {
	long long f0, f1, n;

	cin >> f0 >> f1 >> n;

	n %= 3;
	int bit0, bit1;
	long long ans = 0;

	for (int i = 0; i < 60; i++) {
		bit0 = (f0 >> i) & 1;
		bit1 = (f1 >> i) & 1;

		ans |= pattern[(bit0 << 1) | bit1][n] << i;
	}

	cout << ans << endl;
	return 0;
}
0