A12803 | XORinacci
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows:
- $f(0) = a$ ;
- $f(1) = b$ ;
- $f(n) = f(n-1) \oplus f(n-2)$ when $n > 1$ , where $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
You are given three integers $a$ , $b$ , and $n$ , calculate $f(n)$ .
You have to answer for $T$ independent test cases.
- $f(0) = a$ ;
- $f(1) = b$ ;
- $f(n) = f(n-1) \oplus f(n-2)$ when $n > 1$ , where $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
You are given three integers $a$ , $b$ , and $n$ , calculate $f(n)$ .
You have to answer for $T$ independent test cases.
输入格式
The input contains one or more independent test cases.
The first line of input contains a single integer $T$ ( $1 \le T \le 10^3$ ), the number of test cases.
Each of the $T$ following lines contains three space-separated integers $a$ , $b$ , and $n$ ( $0 \le a, b, n \le 10^9$ ) respectively.
The first line of input contains a single integer $T$ ( $1 \le T \le 10^3$ ), the number of test cases.
Each of the $T$ following lines contains three space-separated integers $a$ , $b$ , and $n$ ( $0 \le a, b, n \le 10^9$ ) respectively.
输出格式
For each test case, output $f(n)$ .
输入输出样例
输入 #1
3 3 4 2 4 5 0 325 265 1231232
输出 #1
7 4 76
In the first example, $f(2) = f(0) \oplus f(1) = 3 \oplus 4 = 7$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted