#abc309c. C - Medicine
C - Medicine
Score : points
问题陈述
医生Snuke为高桥开了种药。从开药的那天(包括开药的那天)起,在接下来的天内,他必须服用第种药的片药片。他不需要服用任何其他药物。
假设开药的那天为第天。在第天或之后,他必须服用片或更少药片的第一天是什么时候?
以上为 kimi GPT 翻译,仅供参考。
Problem Statement
Snuke the doctor prescribed kinds of medicine for Takahashi. For the next days (including the day of the prescription), he has to take pills of the -th medicine. He does not have to take any other medicine.
Let the day of the prescription be day . On or after day , when is the first day on which he has to take pills or less?
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If Takahashi has to take pills or less on day for the first time on or after day , print .
Sample Input 1
4 8
6 3
2 5
1 9
4 2
Sample Output 1
3
On day , he has to take , and pills of the -st, -nd, -rd, and -th medicine, respectively. In total, he has to take pills on this day, which is not pills or less. On day , he has to take , and pills of the -st, -nd, and -th medicine, respectively. In total, he has to take pills on this day, which is not pills or less. On day , he has to take and pills of the -st and -th medicine, respectively. In total, he has to take pills on this day, which is pills or less for the first time.
Thus, the answer is .
Sample Input 2
4 100
6 3
2 5
1 9
4 2
Sample Output 2
1
Sample Input 3
15 158260522
877914575 2436426
24979445 61648772
623690081 33933447
476190629 62703497
211047202 71407775
628894325 31963982
822804784 50968417
430302156 82631932
161735902 80895728
923078537 7723857
189330739 10286918
802329211 4539679
303238506 17063340
492686568 73361868
125660016 50287940
Sample Output 3
492686569
update @ 2024/3/10 08:45:57