Hello peoples I am trying to solve a problem and facing Runtime Error and from my perspective the solution is correct.
This doesn’t make sense to me because it’s running fine and after submiting getting runtime error
My code
# cook your dish here
T = int(input())
while(T!=0):
N = int(input())
Min = 10**(N-1)
Max = 10**N
for i in range(Min,Max):
if(i%3==0 and i%9!=0 and i%2==1):
print(i)
break
T -= 1
@vinamrayadav
N is upto 10^4 which will make min very big that its not possible to store it in any data type .
this question has a very interesting logic.
just refer my c++ code u will get it .
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=0;i<n-1;i++)
cout<<9;
cout<<3;
cout<<endl;
}
return 0;
}
while (T--) {
int N;
cin >> N;
int Min = pow(10, N - 1);
int Max = pow(10, N);
for (int i = Min; i < Max; i++) {
if (i % 3 == 0 && i % 9 != 0 && i % 2 == 1) {
cout << i << endl;
break;
}
}
}
return 0;