My issue
My code
#include <iostream>
#include<bitset>
#include<math.h>
using namespace std;
string toBinary(int n)
{
string r;
while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
return r;
}
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
string ans;
cin>>n;
int i = pow(2,n-1)+1;
ans = toBinary(i);
cout<<ans<<endl;
}
return 0;
}
Where is the error in my code?
Problem Link: ZOOZ Problem - CodeChef