# Help me in solving MAKEDIV3 problem

### My issue

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

``````

Learning course: Jump from 2* to 3*
Problem Link: CodeChef: Practical coding for everyone

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() {
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;
}
``````

Thank you so much
I got it now

include
using namespace std;

int main() {
int T;
cin >> T;

``````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;
``````

}

1 Like