I can’t understand the solution after watching video, sobplease give your solution for this problem and also verify my given solution:
int N,T,quo,K,step;
int j=0;
cin>>T;
//test case loop
for(int i=1;i<=T;i++){
cin>>N;
//find K
for(int dig=1;dig<=N;dig++){
quo= (dig/pow(2,j));
if(quo==1){
K=dig;
j++;
}
}
//find steps
step=1+(N-K);
cout<<step;
}
Incredible hulk problem
I run my code on my mobile compiler it will show correct results. But CB compiler runs an error
I run my code on my mobile compiler it will show correct results. But CB compiler runs an error.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.