248913591 Here I use directly pow function in cout; so it gives a value which is in power. But when I store the it one integer varible than it gives direct value. so in contest time or problem solving time if we use directly pow function in cout it will gives error. have anyone opinion about this to ignore this problem using pow function directly in cout .
Wrong Solution
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
long long n;
cin>>n;
int a=log2(n);
int ans=pow(2,a);
cout<<ans<<endl;
}
return 0;
}
Right solution
~~~~~ ~~~~~ #include<bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ long long n; cin>>n; int a=log2(n); int ans=pow(2,a); cout<<ans<<endl; } return 0; } ~~~~~ ~~~~~