This is the code I have typed for Big Multiplication and got correct output in IDE but it shows wrong answer when I submit what is wrong.

#include

#include<stdio.h>

using namespace std;

int main()

{

long int m,n,xr,yr;

int t,rem,x,y,i;

scanf("%d",&t);

for(i=0;i<t;i++)

{

scanf("%d %d",&m,&n);

x=m/3;

xr=m-(x*3);*

y=n/3;

yr=n-(x3);

rem=(xr*yr)%3;

printf("%d\n",rem);

}

return 0;

}

As the contest is now over I shall answer your question

See the question asked The digits that a single number contained where over 100000 digits so long long int is

not the correct data type for the question. The input data type should be a string or a 1-D character array.

You can do this question by using Boost Library or

Big Int library. But if you want to do it without this then:-

The question asks you to multiply the numbers and the calculate it’s remainder modulo 3

Now it is a well known fact that a number modulo 3 is equal to sum of its digits modulo 3

for eg:-

11284%3=1=(1+1+2+8+4)%3

So for a string just calculate the sum of all int(indices) -‘0’(because int(c[i]) will contain the ascii

value of the character.

After summation of each string separately calculate it’s modulo with 3 multiply the result of the 2 string

the again calculate modulo 3 as(a * b)%3=((a%3) * (b%3))%3

I hope this helped:) Happy coding cheers!!

1 Like