Well, someone got it accepted, so we might be missing something. I use BigInt and also print 0 if exponents don't add up to n (and they don't in some cases - unless input per test case is in more than 3 lines, I haven't considered that).
I have got it accepted. There can be inputs for which z1+z2+..+zk > n, then I made n = z1+z2+...+zk, and returned the result. But I think that the output should be 0.
It is not right. I have informed the judges about this problem, but they havent replied.
Anyway - they should've tested judge's data in this volume or at least get someone to test it for them. It seems every other problem has something wrong with its I/O. And there are a few problems that shouldn't be solvable under the given constraints, but they are - those problem statements should be changed, too. (e.g n=1000000 and m <= n*(n+1)/2 ?!?)
sakhassan wrote:I dont know what's worng
with this input ?
100
5
90 4 3 2 1
The output of your input exceeds 32 bit int. So, it is not a valid input. And you can use 'int' instead of 'double'(precision error!). Read my previous posts. I hope you will get some help.
There's no need to use big integers to solve this problem. The key is to find a recurrence for the multinomial coefficient involving only sums and/or products. It is guaranteed to not overflow.