CF1037A.Packets

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You have nn coins, each of the same value of 11.

Distribute them into packets such that any amount xx (1≤x≤n1 \leq x \leq n) can be formed using some (possibly one or all) number of these packets.

Each packet may only be used entirely or not used at all. No packet may be used more than once in the formation of the single xx, however it may be reused for the formation of other xx's.

Find the minimum number of packets in such a distribution.

你有 nn 枚硬币,每枚硬币的价值均为 11。

将它们分配到若干个“包”(packets)中,使得对于任意金额 xx(其中 1≤x≤n1 \leq x \leq n),都能通过选取其中若干个(可能是一个,也可能是全部)包来恰好凑出 xx。

每个包只能被完整使用或完全不使用;在凑出某一个特定的 xx 时,每个包最多只能使用一次;但同一个包可以被重复用于凑出不同的 xx 值。

求满足上述条件的最少包的数量。

输入格式

The only line contains a single integer nn (1≤n≤1091 \leq n \leq 10^9) — the number of coins you have.

唯一的一行包含一个整数 nn(1≤n≤1091 \leq n \leq 10^9)——你拥有的硬币数量。

输出格式

Output a single integer — the minimum possible number of packets, satisfying the condition above.

输出一个整数——满足上述条件的最少数据包数量。

输入输出样例

  • 输入#1

    6

    输出#1

    3
  • 输入#2

    2

    输出#2

    2

说明/提示

In the first example, three packets with 11, 22 and 33 coins can be made to get any amount xx (1≤x≤61\leq x\leq 6).

  • To get 11 use the packet with 11 coin.
  • To get 22 use the packet with 22 coins.
  • To get 33 use the packet with 33 coins.
  • To get 44 use packets with 11 and 33 coins.
  • To get 55 use packets with 22 and 33 coins
  • To get 66 use all packets.

In the second example, two packets with 11 and 11 coins can be made to get any amount xx (1≤x≤21\leq x\leq 2).

在第一个例子中,可以制作三包硬币,分别包含 11、22 和 33 枚硬币,从而得到任意金额 xx(1≤x≤61\leq x\leq 6)。

  • 要得到 11,使用含 11 枚硬币的那包。
  • 要得到 22,使用含 22 枚硬币的那包。
  • 要得到 33,使用含 33 枚硬币的那包。
  • 要得到 44,使用含 11 枚和 33 枚硬币的两包。
  • 要得到 55,使用含 22 枚和 33 枚硬币的两包。
  • 要得到 66,使用全部三包。

在第二个例子中,可以制作两包硬币,每包均含 11 枚硬币,从而得到任意金额 xx(1≤x≤21\leq x\leq 2)。

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

首页