a843: [黃]Reward Reward Reward ...
Tags :
Accepted rate : 13人/16人 ( 81% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-10-22 14:28

Content

【Background】

The children of Red-Sun Kindergarten have started to distribute candy!

【Description】

There are n children in kindergarten, and you are one of them. It is guaranteed that n >= 2.

One day you find an "infinite number" of candies in the garden, and you plan to take some candies back and distribute them to the children in the kindergarten.

Since you are just an ordinary kindergarten child, your physical strength is limited, and you can only go back with R lumps at most.

But taking too little is not enough, so you should at least take L candy back. It is guaranteed that n ≤ L ≤ R.

That is, if you take k lumps, then you need to guarantee that L ≤ k ≤ R.

If you take k pieces of candy, you will put the k pieces of candy in the basket and ask everyone to divide the candy according to the following scheme: as long as there are no less than n pieces of candy in the basket, all n children in the kindergarten (including yourself ) take exactly 1 candy from the basket until there are fewer than n candies in the basket. The rest of the candy in the basket is yours, at this point they are your reward for moving the candy.

As a high-quality kindergartener, you want to make the number of candies as a reward for moving candies (instead of the total number of candies you end up getting!) as much as possible!

So you need to write a program that takes n, L, R, and output the maximum number of candies you can get as a reward for moving candies.

Input

Enter a line containing three positive integers n, L, R, representing the number of children, the lower and upper bounds of the number of candies.

 

【Data range】

guaranteed for all data : 2 ≤ nLR ≤ 109 

 

Output

Output a line with an integer representing the maximum number of candies you can get as a reward for moving candies.

Sample Input #1
7 16 23
Sample Output #1
6
Sample Input #2
10 14 18
Sample Output #2
8
測資資訊:
記憶體限制: 64 MB
不公開 測資點#0 (15%): 1.0s , <1K
不公開 測資點#1 (1%): 1.0s , <1K
不公開 測資點#2 (1%): 1.0s , <1K
不公開 測資點#3 (8%): 1.0s , <1K
不公開 測資點#4 (8%): 1.0s , <1K
不公開 測資點#5 (15%): 1.0s , <1K
不公開 測資點#6 (11%): 1.0s , <1K
不公開 測資點#7 (11%): 1.0s , <1K
不公開 測資點#8 (15%): 1.0s , <1K
不公開 測資點#9 (15%): 1.0s , <1K
Hint :

 

【Example #1 Explanation】

Take k=20 candies and put them in the basket.

The number of candies in the basket is now 20 >= n = 7, so all children get a piece of candy;

The number of candies in the basket now becomes 13 >= n = 7, so all children get a piece of candy;

The number of candies in the basket is now 6 < n = 7, so these 6 candies are your reward for moving candies.

It is easy to find that the number of candies you get as a reward for moving candies cannot exceed 6 pieces (otherwise, the number of candies in the basket is still no less than n at the end, and each child needs to continue to take one piece), so the answer is 6.

 

Tags:
出處:
LouisFox [管理者:
admin (Judge)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」