A1326 | [COCI-2015_2016-contest7]#3 OZLJEDA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Due to the frantical usage of the racket to kill flies, Marin has sustained a serious bodily injury known to the medical community as epicondylitis lateralis humeri. His grandma has advised smearing rakija over it, the doctor has prescribed a strong painkiller, but Marin has ignored every single advice and decided to look for the answer in integer sequences.
He has discovered a previously undiscovered sequence of integers and called it the xorbonacci sequence.
The n th element in the sequence is denoted with xn. The sequence is defined recursively in the following way:
x1 = a1, x2 = a2, ...
xk = ak, xn = xn−1 ⊕ xn−2 ⊕ ... ⊕ xn−k, n > k Because of a reason only known to Marin, he determined that all his sorrows will go away if you answer his Q queries defined with numbers l and r. The answer to the query is represented with the value xl ⊕ xl+1 ⊕ ... ⊕ xr−1 ⊕ xr Help Marin and answer his queries.
Please note: The operation ⊕ is the operation of binary XOR.
He has discovered a previously undiscovered sequence of integers and called it the xorbonacci sequence.
The n th element in the sequence is denoted with xn. The sequence is defined recursively in the following way:
x1 = a1, x2 = a2, ...
xk = ak, xn = xn−1 ⊕ xn−2 ⊕ ... ⊕ xn−k, n > k Because of a reason only known to Marin, he determined that all his sorrows will go away if you answer his Q queries defined with numbers l and r. The answer to the query is represented with the value xl ⊕ xl+1 ⊕ ... ⊕ xr−1 ⊕ xr Help Marin and answer his queries.
Please note: The operation ⊕ is the operation of binary XOR.
输入格式
The first line of input contains the integer K (1 6 K 6 100 000) from the task.
The following line contains K integers that represent the first K elements in the xorbonacci sequence.
All numbers are smaller than 1018 .
The following line contains the integer Q (1 6 Q 6 106 ) from the task.
The i th of the following Q lines contains two integers li and ri (1 6 li 6 ri 6 1018) that represent Marin’s i th query.
The following line contains K integers that represent the first K elements in the xorbonacci sequence.
All numbers are smaller than 1018 .
The following line contains the integer Q (1 6 Q 6 106 ) from the task.
The i th of the following Q lines contains two integers li and ri (1 6 li 6 ri 6 1018) that represent Marin’s i th query.
输出格式
Each of the following Q lines of output must contain the answers to Marin’s queries, the order being the same as the input.
输入输出样例
输入 #1
4 1 3 5 7 3 2 2 2 5 1 5
输出 #1
3 1 0
输入 #2
5 3 3 4 3 2 4 1 2 1 3 5 6 7 9
输出 #2
0 4 7 4
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted