CF991C.Candies

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

After passing a test, Vasya got himself a box of nn 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 kk, same for all days. After that, in the morning he eats kk candies from the box (if there are less than kk candies in the box, he eats them all), then in the evening Petya eats 10%10\% of the candies remaining in the box. If there are still candies left in the box, the process repeats — next day Vasya eats kk candies again, and Petya — 10%10\% of the candies left in a box, and so on.

If the amount of candies in the box is not divisible by 1010, Petya rounds the amount he takes from the box down. For example, if there were 9797 candies in the box, Petya would eat only 99 of them. In particular, if there are less than 1010 candies in a box, Petya won't eat any at all.

Your task is to find out the minimal amount of kk that can be chosen by Vasya so that he would eat at least half of the nn candies he initially got. Note that the number kk must be integer.

通过测试后,瓦西娅得到了一盒共 nn 颗糖果。他决定每天早上吃相同数量的糖果,直到盒中糖果被吃完为止。然而,佩佳也注意到了这盒糖果,并决定从中拿走一些。

因此,吃糖果的过程如下:最开始,瓦西娅选定一个固定的整数 kk(该值在所有天中保持不变)。之后,每天早上他从盒中吃掉 kk 颗糖果(若盒中剩余糖果少于 kk 颗,则全部吃掉);接着在晚上,佩佳吃掉盒中剩余糖果的 10%10\%。若盒中仍有糖果剩下,则该过程重复进行——第二天早上瓦西娅再次吃掉 kk 颗糖果,晚上佩佳再吃掉盒中剩余糖果的 10%10\%,依此类推。

当盒中糖果数量不能被 1010 整除时,佩佳取走的糖果数量向下取整。例如,若盒中有 9797 颗糖果,佩佳仅吃掉其中的 99 颗。特别地,若盒中糖果少于 1010 颗,则佩佳当天不吃任何糖果。

你的任务是找出瓦西娅可选择的最小整数 kk,使得他最终吃到的糖果总数不少于最初 nn 颗糖果的一半。注意:kk 必须为整数。

输入格式

The first line contains a single integer nn (1≤n≤10181 \leq n \leq 10^{18}) — the initial amount of candies in the box.

第一行包含一个整数 nn(1≤n≤10181 \leq n \leq 10^{18})——盒子中初始的糖果数量。

输出格式

Output a single integer — the minimal amount of kk that would allow Vasya to eat at least half of candies he got.

输出一个整数——使得瓦西娅能够吃到他所获得糖果总数至少一半的最小 kk 值。

输入输出样例

  • 输入#1

    68

    输出#1

    3

说明/提示

In the sample, the amount of candies, with k=3k=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→068 \to 65 \to 59 \to 56 \to 51 \to 48 \to 44 \to 41 \\ \to 37 \to 34 \to 31 \to 28 \to 26 \to 23 \to 21 \to 18 \to 17 \to 14 \\ \to 13 \to 10 \to 9 \to 6 \to 6 \to 3 \to 3 \to 0.

In total, Vasya would eat 3939 candies, while Petya — 2929.

在样例中,当 k=3k=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→068 \to 65 \to 59 \to 56 \to 51 \to 48 \to 44 \to 41 \\ \to 37 \to 34 \to 31 \to 28 \to 26 \to 23 \to 21 \to 18 \to 17 \to 14 \\ \to 13 \to 10 \to 9 \to 6 \to 6 \to 3 \to 3 \to 0。

总计,瓦夏吃了 3939 颗糖果,而佩佳吃了 2929 颗。

输入解题思路,AI测评打分。不知道怎么写?

首页