VK Cup 2016 - Round 3
F
Bears and Juice
Codeforces
2900
原题
← EG →
翻译中…

There are $*n*$ bears in the inn and $*p*$ places to sleep. Bears will party together for some number of nights (and days).

翻译中…

Bears love drinking juice. They don't like wine but they can't distinguish it from juice by taste or smell.

翻译中…

A bear doesn't sleep unless he drinks wine. A bear must go to sleep a few hours after drinking a wine. He will wake up many days after the party is over.

翻译中…

Radewoosh is the owner of the inn. He wants to put some number of barrels in front of bears. One barrel will contain wine and all other ones will contain juice. Radewoosh will challenge bears to find a barrel with wine.

翻译中…

Each night, the following happens in this exact order:

翻译中…
  1. Each bear must choose a (maybe empty) set of barrels. The same barrel may be chosen by many bears.
  2. Each bear drinks a glass from each barrel he chose.
  3. All bears who drink wine go to sleep (exactly those bears who chose a barrel with wine). They will wake up many days after the party is over. If there are not enough places to sleep then bears lose immediately.
翻译中…

At the end, if it's sure where wine is and there is at least one awake bear then bears win (unless they have lost before because of the number of places to sleep).

翻译中…

Radewoosh wants to allow bears to win. He considers $*q*$ scenarios. In the $*i*$-th scenario the party will last for $*i*$ nights. Then, let $*R*_{*i*}$ denote the maximum number of barrels for which bears surely win if they behave optimally. Let's define image. Your task is to find image, where image denotes the exclusive or (also denoted as XOR).

翻译中…

Note that the same barrel may be chosen by many bears and all of them will go to sleep at once.

翻译中…

Input

翻译中…

The only line of the input contains three integers $*n*$, $*p*$ and $*q*$ ($1 ≤ *n* ≤ 10^{9}$, $1 ≤ *p* ≤ 130$, $1 ≤ *q* ≤ 2 000 000$) — the number of bears, the number of places to sleep and the number of scenarios, respectively.

翻译中…

Output

翻译中…

Print one integer, equal to image.

翻译中…

Note

翻译中…

In the first sample, there are $5$ bears and only $1$ place to sleep. We have $*R*_{1} = 6, *R*_{2} = 11, *R*_{3} = 16$ so the answer is image. Let's analyze the optimal strategy for scenario with $2$ days. There are $*R*_{2} = 11$ barrels and $10$ of them contain juice.

翻译中…
  • In the first night, the $*i*$-th bear chooses a barrel $*i*$ only.
  • If one of the first $5$ barrels contains wine then one bear goes to sleep. Then, bears win because they know where wine is and there is at least one awake bear.
    • But let's say none of the first $5$ barrels contains wine. In the second night, the $*i*$-th bear chooses a barrel $5 + *i*$.
    • If one of barrels $6 – 10$ contains wine then one bear goes to sleep. And again, bears win in such a situation.
      • If nobody went to sleep then wine is in a barrel $11$.
翻译中…

In the second sample, there is only one bear. He should choose an empty set of barrels in each night. Otherwise, he would maybe get wine and bears would lose (because there must be at least one awake bear). So, for any number of days we have $*R*_{*i*} = 1$. The answer is image.

翻译中…

样例

Input #1
5 1 3
Output #1
32
InputCopy OutputCopy
Input #2
1 100 4
Output #2
4
InputCopy OutputCopy
Input #3
3 2 1
Output #3
7
InputCopy OutputCopy
Input #4
100 100 100
Output #4
381863924
InputCopy OutputCopy
题目信息
题号
643F
时间限制
5 s
内存限制
256 MB
标签
动态规划
数学
折半搜索

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。