Codeforces•Jun 16, 2025
Packets
Hazrat Ali
Codeforces
Distribute them into packets such that any amount x (1≤x≤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 x, however it may be reused for the formation of other xs.
Find the minimum number of packets in such a distribution.
Input
The only line contains a single integer n (1≤n≤10) the number of coins you have.
Output
Output a single integer the minimum possible number of packets, satisfying the condition above.
Examples
Input
6
Output
3
Input
2
Output
2
Solution
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int ans = log2(n) + 1;
cout << ans << endl;
return 0;
}