Water

Luogu
IDLGP10056
Time1000ms
Memory512MB
DifficultyP1
数学洛谷原创O2优化洛谷月赛
有 $n$ 个杯子,每个杯子的容积是 $a$,且初始装有 $b$ 体积水。 你可以进行任意次操作,每次操作选择任意两个杯子,将其中一个杯子内的水**全部倒入**另一个杯子中,但是过程中**杯子里的水不能溢出(即不能超过其容积)**,如果不满足则无法进行该操作。 请通过合法的操作,最大化装有最多水的杯子里水的体积。 ## Input 一行三个整数,表示 $a,b,n$。 ## Output 一行一个整数 $x$,表示最多水的杯子内的水的体积。 [samples] ## Note #### 【样例 1 解释】 假设现在有两个杯子 $A,B$,可以先把 $A$ 中的全部水倒入 $B$ 中,此时 $A$ 有 $0$ 升水,$B$ 有 $4$ 升水,结束操作。此时最多水杯子内水的数量为 $4$。 #### 【数据规模与约定】 | 测试点编号 | $n\le$ | 特殊性质 | | :----------: | :----------: | :----------: | | $1\sim2$ | $10^5$ | 保证无论如何操作都不会溢出 | | $3 \sim 6$ | $10^6$ | 无 | | $7 \sim 10$ | $10^9$ | 无 | 对于 $100\%$ 的数据,$1 \le n \le 10^9$,$1\le a\le 10^{18}$,$1\le b\le \min(a,10^9)$。
Samples
Input #1
5 2 2 
Output #1
4
Input #2
11 5 7 
Output #2
10
API Response (JSON)
{
  "problem": {
    "name": "Water",
    "description": {
      "content": "有 $n$ 个杯子,每个杯子的容积是 $a$,且初始装有 $b$ 体积水。 你可以进行任意次操作,每次操作选择任意两个杯子,将其中一个杯子内的水**全部倒入**另一个杯子中,但是过程中**杯子里的水不能溢出(即不能超过其容积)**,如果不满足则无法进行该操作。 请通过合法的操作,最大化装有最多水的杯子里水的体积。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P1"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10056"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "有 $n$ 个杯子,每个杯子的容积是 $a$,且初始装有 $b$ 体积水。\n你可以进行任意次操作,每次操作选择任意两个杯子,将其中一个杯子内的水**全部倒入**另一个杯子中,但是过程中**杯子里的水不能溢出(即不能超过其容积)**,如果不满足则无法进行该操作。\n\n请通过合法的操作,最大化装有最多水的杯子里水的体积。\n\n## Input\n\n一行三个整数,表示 $a,b,n$。\n\n## Output\n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments