Bella ciao problem

I know discussing anything related to an ongoing contest isn’t acceptable. I have already solved the problem but I have a doubt related to constraint and online judge.
In problem bella ciao - june long challenge, the constraint mentioned in the problem for D,d,P,Q is in between 1 - 10^6. I wrote a cpp code and used int data type for these inputs, this gave me WA and when I used long then AC. Why?
In c++, int range is in between -2x10^9 to 2x10^9.
I hope, this post doesn’t violate any rules and I didn’t reveal anything related to the solution.

Thanks :slight_smile:

take 2 ints
a = 109
b = 109

multiply them
c = a*b

what does c look like (not 1018)
now you know what goes wrong

11881 :stuck_out_tongue:

LaTeX to the rescue: use


instead, to avoid mangling.


a and b are int (am I right)? c needs to be some bigger data type long int or long long int, which I know but why a and b needs to be bigger data type? that’s my question

you can try yourself multiple times with different datatypes for a and b

The topic you are loooking for is called. Type Casting.
But in short answer is yes long long int is needed to make life simpler

Thanks for mentioning

1 Like