This is Discussion thread about Incredible Hulk
Discussion About Incredible Hulk
What’s the error?
I have cleared all the given test cases and I also ran some of my own, it all worked fine but I’m getting Wrong answer after submitting.
#include<bits/stdc++.h>
using namespace std;
int main(){
int test;
cin >> test;
while(test--){
int n;
cin >> n;
int logi = (int) log2(n);
int power = (int) pow(2, logi);
int step = n - power + 1;
cout << step << endl;
}
}
#include
using namespace std;
int steps(int n){
int bit=0;
while(n!=0){
if(n&1){
bit++;
}
n=n>>1;
}
return bit;
}
int main(){
int n;
cin>>n;
while(n–){
int num;
cin>>num;
cout<<steps(num)<<endl;
}
}