CF991C.Candies
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After passing a test, Vasya got himself a box of n candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.
This means the process of eating candies is the following: in the beginning Vasya chooses a single integer k, same for all days. After that, in the morning he eats k candies from the box (if there are less than k candies in the box, he eats them all), then in the evening Petya eats 10% of the candies remaining in the box. If there are still candies left in the box, the process repeats — next day Vasya eats k candies again, and Petya — 10% of the candies left in a box, and so on.
If the amount of candies in the box is not divisible by 10, Petya rounds the amount he takes from the box down. For example, if there were 97 candies in the box, Petya would eat only 9 of them. In particular, if there are less than 10 candies in a box, Petya won't eat any at all.
Your task is to find out the minimal amount of k that can be chosen by Vasya so that he would eat at least half of the n candies he initially got. Note that the number k must be integer.
通过测试后,瓦西娅得到了一盒共 n 颗糖果。他决定每天早上吃相同数量的糖果,直到盒中糖果被吃完为止。然而,佩佳也注意到了这盒糖果,并决定从中拿走一些。
因此,吃糖果的过程如下:最开始,瓦西娅选定一个固定的整数 k(该值在所有天中保持不变)。之后,每天早上他从盒中吃掉 k 颗糖果(若盒中剩余糖果少于 k 颗,则全部吃掉);接着在晚上,佩佳吃掉盒中剩余糖果的 10%。若盒中仍有糖果剩下,则该过程重复进行——第二天早上瓦西娅再次吃掉 k 颗糖果,晚上佩佳再吃掉盒中剩余糖果的 10%,依此类推。
当盒中糖果数量不能被 10 整除时,佩佳取走的糖果数量向下取整。例如,若盒中有 97 颗糖果,佩佳仅吃掉其中的 9 颗。特别地,若盒中糖果少于 10 颗,则佩佳当天不吃任何糖果。
你的任务是找出瓦西娅可选择的最小整数 k,使得他最终吃到的糖果总数不少于最初 n 颗糖果的一半。注意:k 必须为整数。
输入格式
The first line contains a single integer n (1≤n≤1018) — the initial amount of candies in the box.
第一行包含一个整数 n(1≤n≤1018)——盒子中初始的糖果数量。
输出格式
Output a single integer — the minimal amount of k that would allow Vasya to eat at least half of candies he got.
输出一个整数——使得瓦西娅能够吃到他所获得糖果总数至少一半的最小 k 值。
输入输出样例
输入#1
68
输出#1
3
说明/提示
In the sample, the amount of candies, with k=3, would change in the following way (Vasya eats first):
68→65→59→56→51→48→44→41→37→34→31→28→26→23→21→18→17→14→13→10→9→6→6→3→3→0.
In total, Vasya would eat 39 candies, while Petya — 29.
在样例中,当 k=3 时,糖果数量的变化过程如下(瓦夏先吃):
68→65→59→56→51→48→44→41→37→34→31→28→26→23→21→18→17→14→13→10→9→6→6→3→3→0。
总计,瓦夏吃了 39 颗糖果,而佩佳吃了 29 颗。
输入解题思路,AI测评打分。不知道怎么写?