No but my question is that an algorithm has to be generic and valid for all kinds of test cases.What the test cases are is an altogether different thing.
i m getting 7028544864737656560892…and apparently it is correct…but still m not getting AC…
Try this : 0A000B99
Your atoi() cannot handle digits with a length of 1000.
Find some other mechanism for comparison.
thanks a lot…!!!
string can do it?
In C/C++ I guess thats the only way to do it.
Java provides you with BigInteger.
And python is the king in such cases…
7028544864737656560892 i’m also getting it’s correct but getting TLE in python code
i’m also getting 7028544864737656560892 but it shows wa
Ohhh…I added the wrong link. I’ve changed that. And corrected for the above cases as well…Still not working.
And Now the code is less generic and more of test case driven…:-/
the ans can have upto 1000 digits…you can not store it using an int and also the NZEC is due to number format exception!!!
@d27v then you must be missing some corner cases.
Have you checked the points @prad_adm has posted above.
@prad_adm : Here is link to my submission, which got AC : http://www.codechef.com/viewplaintext/2290226
I had used long double to store the maximum.
Was it due to the test cases or long double is sufficient to store values upto 10^1000.
Was really surprised at AC. Initially I started with long long int, but got WA. Then I switched to long double.
Just curious to know.
@xnon Your code doesn’t produce any output for all zeroes.
Try 00000 or 0000000000 (any string of 0’s), there is no output.
long double can store huge numbers…but sometimes the precision may be lost!!!