当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5593:ZYB's Tree

题目描述
$ZYB$ has a tree with $N$ nodes,now he wants you to solve the numbers of nodes distanced no more than $K$ for each node.
the distance between two nodes$(x,y)$ is defined the number of edges on their shortest path in the tree.

To save the time of reading and printing,we use the following way:

For reading:we have two numbers $A$ and $B$,let $fa_i$ be the father of node $i$,$fa_1=0$,$fa_i=(A*i+B)\%(i-1)+1$ for $ i \in [2,N]$ .

For printing:let $ans_i$ be the answer of node $i$,you only need to print the $xor$ $sum$ of all $ans_i$.
输入解释
In the first line there is the number of testcases $T$.

For each teatcase:

In the first line there are four numbers $N$,$K$,$A$,$B$

$1 \leq T \leq 5$,$1 \leq N \leq 500000$,$1 \leq K \leq 10$,$1 \leq A,B \leq 1000000$
输出解释
For $T$ lines,each line print the ans.

Please open the stack by yourself.

$N \geq 100000$ are only for two tests finally.
输入样例
1
3 1 1 1
输出样例
3
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #65

源链接: HDU-5593

最后修改于 2020-10-25T23:24:02+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1500MS(Java/Others) 131072/131072K(Java/Others)