whats wrong in the code works fine on code::blocks 13.12 ????

int main()
{ unsigned long int N,i,x,y,m;
{ scanf("%d %d",&x,&y);
if (x>y)
if(x%i==0 && y%i==0)
return 0;

I think you are getting wrong answer because you are trying to store a 250 digit number in unsigned long int. Unsigned long int can store only till 10^9 i.e. 9 digits.

use a character array to store digit as the number is very large (upto 250 digits) and c/c++ cant handle such long numbers. :slight_smile:

Hey @Vaibhav Saini

Read this constraint: Each line consists of two number A and B (0 <= A <= 40000 and A <= B < 10^250).

First Thing For WA:

Check this test case:

0 0

Your code fails to produce any output for this case.

Now Constraint: integer that has up to 250 digits which can lead to SIGSEGV RE.

Even unsigned long long int has range: 0 to 18,446,744,073,709,551,615

SO you cannot use integer datatype to store a number which has 250 digits, and so you have to use an array.

small correcttion - 10^9 is 10 digits in fact :stuck_out_tongue:

ohh!! sorry for the miscalculation.
It was a counting error :wink:

can i use double insted of int ?


1 Like

that will also not work bcoz the second number is of 250 digits… u have to use character array to store such large number.

another way is to use languages like python, it can handle any size of number :stuck_out_tongue:

yeah that’s true you may use python as python has big-num library so there is no problem of integer overflow.