結果
問題 | No.64 XORフィボナッチ数列 |
ユーザー |
![]() |
提出日時 | 2016-01-18 03:57:45 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 542 bytes |
コンパイル時間 | 1,339 ms |
コンパイル使用メモリ | 158,052 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 20:22:46 |
合計ジャッジ時間 | 1,871 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
ソースコード
#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;}