1037A.md (1435B)
1 Source: https://codeforces.com/problemset/problem/1037/A 2 3 A. Packets 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You have $n$ coins, each of the same value of $1$. 22 23 Distribute them into packets such that any amount $x$ ($1 \leq x \leq n$) can be formed using some (possibly one or all) number of these packets. 24 25 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 $x$, however it may be reused for the formation of other $x$'s. 26 27 Find the minimum number of packets in such a distribution. 28 29 Input 30 31 The only line contains a single integer $n$ ($1 \leq n \leq 10^9$) — the number of coins you have. 32 33 Output 34 35 Output a single integer — the minimum possible number of packets, satisfying the condition above. 36 37 Examples 38 39 Input 40 41 ``` 42 6 43 ``` 44 45 Output 46 47 ``` 48 3 49 ``` 50 51 Input 52 53 ``` 54 2 55 ``` 56 57 Output 58 59 ``` 60 2 61 ``` 62 63 Note 64 65 In the first example, three packets with $1$, $2$ and $3$ coins can be made to get any amount $x$ ($1\leq x\leq 6$). 66 67 * To get $1$ use the packet with $1$ coin. 68 * To get $2$ use the packet with $2$ coins. 69 * To get $3$ use the packet with $3$ coins. 70 * To get $4$ use packets with $1$ and $3$ coins. 71 * To get $5$ use packets with $2$ and $3$ coins 72 * To get $6$ use all packets. 73 74 In the second example, two packets with $1$ and $1$ coins can be made to get any amount $x$ ($1\leq x\leq 2$).