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

建议使用的浏览器:

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

5565:Clarke and baton

题目描述
Clarke is a patient with multiple personality disorder. One day, Clarke split into $n$ guys, named $1$ to $n$.
They will play a game called Lose Weight. Each of Clarkes has a weight $a[i]$. They have a baton which is always in the hand of who has the largest weight(if there are more than 2 guys have the same weight, choose the one who has the smaller order). The one who holds the baton needs to lose weight. i.e. $a[i]$ decreased by 1, where $i$ is the guy who holds the baton.
Now, Clarkes know the baton will be passed $q$ times. They want to know each one's weight after finishing this game.
输入解释
The first line contains an integer $T(1 \le T \le 10)$, the number of the test cases.
Each test case contains three integers $n, q, seed(1 \le n, q \le 10000000, \sum n \le 20000000, 1 \le seed \le 10^9+6)$, $seed$ denotes the random seed.
$a[i]$ generated by the following code.

  long long seed;
  int rand(int l, int r) {
    static long long mo=1e9+7, g=78125;
    return l+((seed*=g)%=mo)%(r-l+1);
  }

  int sum=rand(q, 10000000);
  for(int i=1; i<=n; i++) {
    a[i]=rand(0, sum/(n-i+1));
    sum-=a[i];
  }
  a[rand(1, n)]+=sum;
输出解释
Each test case print a line with a number which is $(b[1]+1) xor (b[2]+2) xor ... xor (b[n]+n)$, where $b[i]$ is the $ith$ Clarke's weight after finishing the game.
输入样例
1
3 2 1
输出样例
20303

Hint:
At first, $a[1]=20701, a[2]=31075, a[3]=26351$.  
At the first time, $a[2]$ decrease by 1.  
At the second time, $a[2]$ decrease by 1.  
Finally, $a[1]=20701, a[2]=31073, a[3]=26351$. So answer is $(20701+1)xor(31073+2)xor(26351+3)=20303$.  
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5565

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

共提交 0

通过率 --%
时间上限 内存上限
12000/6000MS(Java/Others) 524288/524288K(Java/Others)