logo AlgoBeat OnlineJudge
登录 注册

#214641. [NCPC 2025] Jump

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

:::align{center}

Ballsout at Metal Frenzy Open Air 2022, image by S. Bollmann, commons.wikimedia.org

:::


The Unsightly Halfwits are putting on a wild concert in their natural habitat of Húsavík. Their lead singer, Sveinn "Springheel" Jónsson, is leaping about the stage with vigorous energy, turning every note into a spectacle. But keeping in rhythm while bouncing so chaotically is no easy task, and you can’t help but wonder how long he can keep this up.

Sveinn starts with an energy level of . The song plays a beat exactly every milliseconds. His first jump launches at time , perfectly in sync with the music. As long as his energy is strictly positive (), each jump lasts exactly milliseconds. When his energy runs out with , he collapses and the show is over. If he still has energy after landing, he immediately springs up again for the next jump. When Sveinn lands exactly on a beat, he gains energy from sheer enjoyment. But if he's even slightly off-beat, his energy drops by .

输入格式

The input consists of:

  • One line with two integers , the number of milliseconds between beats and the initial energy level of the lead singer. These will satisfy and .

输出格式

Output a single integer, the number of milliseconds that will pass before Sveinn stops jumping. If he never stops, instead print .

样例

样例输入 1

7 9

样例输出 1

59

样例输入 2

7 4

样例输出 2

infinity

样例输入 3

100001 123123123

样例输出 3

7581167638793024