結果

問題 No.64 XORフィボナッチ数列
ユーザー DrafearDrafear
提出日時 2016-01-18 03:57:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 1,232 ms
コンパイル使用メモリ 160,136 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 00:33:31
合計ジャッジ時間 1,863 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int solve(int f0, int f1, ll N) {
	if (f0 == 0 && f1 == 0) {
		return 0;
	}
	int idx = 0;
	if (f0 == 0 && f1 == 1) {
		idx = 2;
	}
	else if (f0 == 1 && f1 == 0) {
		idx = 1;
	}
	int a = (N + idx) % 3;
	return a == 2 ? 0 : 1;
}

int main() {
	ll f0, f1, N; cin >> f0 >> f1 >> N;
	ll f = 0;
	for (int i = 0; (1LL << i) <= max(f0, f1); ++i) {
		int a = (f0 & (1LL << i)) ? 1 : 0;
		int b = (f1 & (1LL << i)) ? 1 : 0;
		f |= (ll)solve(a, b, N) << i;
	}
	cout << f << endl;
}
0