Chef and Dynamo ( Jan Challenge 2020)

I wrote same code, one is in Python and another one is in C++. Actually I m C++ preferred coder but knows basic Python. When I wrote the code in C++, I got 20 points. I tried everything, still, I got 20 points. At last, I have to do it in python since it was a very easy Question.

Although I got 100 points for this, still want to know the reason, why my code didn’t get 100 points in C++.

Because of Data type. See the constraints :slight_smile:

in c++ i have seen this that if you try to use power function and do multiple operation in same line for large values it gives WA . your code is failing for
input :- N=18 ,A=B=D=999999999999999999

i was facing same problem then is used this

	    s = a+2*temp;

used a temp variable to store 10^N and then it worked fine .
here’s your code working properly now :-


Bro I have used unsigned long long int.
I think this is not the problem.

Yes, its working.
Thanks mate, I will keep this point in my mind.

pow() returns a floating point value, and due to floating point arithmetic, it is probably 99.999 however, due to integer truncation, even 99.999… gets truncated down to 99

Hi all,
My approach was to take S as largest N digit no. possible, C as minimum N digit no. possible and then E will be simply (S-a-b-C-d), however, I was not able to pass even one test case.
eg. N = 4
a = 1234, S = 9999, b = 1111, c = 1000, d = 1423, e = s-a-b-c-d = 6231
Is there something wrong with the approach, could the tester give something that will make e become negative like a = 8000, b = 3000 ?

a,b,c,d,e < 10^n
S < 5*(10^n)

See the constrainsts

ohh, my bad, I tried so much to solve to this question but couldn’t, thanks for pointing out, will try it again with the constraints in mind. :sweat_smile: