My issue
I am adding 0 for n>=2 but for test case n = 2 its failing. My O/P is 30 which is correct, it is divisible by 3 but not by 9
My code
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#define ll long long
#define ld long double
using namespace std;
bool ispowerof2 ( ll num )
{
if ( ( num & ( num - 1 ) ) == 0 )
return 1;
return 0;
}
ll getSqrt(ll x) {
ll lo = 0, hi = 1e9, c = 0;
while(lo <= hi) {
ll mid = (lo + hi) / 2;
if((mid * mid) <= x) {
c = mid;
lo = mid + 1;
} else hi = mid - 1;
}
return c;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
string s ="3";
n--;
while(n>0){
s+='0';
n--;
}
cout<<s<<endl;
}
return 0;
}
Learning course: Jump from 2* to 3*
Problem Link: Make it Divisible Practice Problem in Jump from 2* to 3* - CodeChef