Hello, I am solving this problem and
I am getting Wrong answer when submitting my solution even the results are true on my computer
I am getting:
Wrong answer on test 1 for Microsoft visual c++ 2010
Wrong answer on test 9 for GNU c++ 4.9.2
Wrong answer on test 9 for GNU c++11 4.9.2
Even my answer is correct in the three cases
So what could the problem be ?
try to reset your arrays.
I've put larger size(larger than I need) for each array and I got it accepted but I don't know the reason
The problem wasn't in compilers, it was in your code :) Look, in the last loop you're using C(i,k). But here i starts from zero while k can be big enough. You just have to use the fact that C(i,k)=0 when k>i: 11176479 — AC.
thank you very mush, but I still don't know why the answers on my computer are correct
Wierd overflow, I think. Let n<m, then n-m<0. So, in C(n,m) you're trying to access inv_fact[] at some strange position. In fact, that must cause an error (out of array bounds), but you were lucky enough and it was just accessing some zero values. Not sure if it's so important to study what exactly happened here... It's better to remember initialize everything correctly :)
your are right , thank you very mush