My issue
Why the answer required for n=3 is 3 when i am using the solution which was accepted shouldn’t it be {1,3} , {2} i can guess all 1 by {1,3} , 2 by {2} and 3 by {1,3} , {2} by adding 1st 2 elements 1+2.
My code
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<long long>
#define ff first
#define ss second
#define pii pair<int,int>
int count(ll n){
int cnt = 0;
while(n>1){
cnt++;
n = n/2;
}
return cnt;
}
void solve(){
ll n;
cin>>n;
int cnt = count(n);
cout<<cnt+1<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
Problem Link: Aditi and Magic Trick Practice Coding Problem