@above Better you ask it on spoj forum On Sun, Jun 19, 2011 at 7:27 PM, saurabh singh <[email protected]> wrote:
> I am getting WA for this problem.I dont know whether its case of overflow > or I have come up with a wrong formula, > https://www.spoj.pl/problems/CHAIR/ > I am coding in python so I dont think there is probblem of overflow. > > def f(n): > if n<0: > return 0 > if n==0: > return 1 > i=n > prod=1 > while i>0 : > prod*=i > i-=1 > return prod > n=input() > k=input() > if k==1: > print n > elif 2*k>n: > print 0 > else : > x=f(n-1) > y=f(n-k)*f(k) > print (x-y)%1000000003 > > > -- > Saurabh Singh > B.Tech (Computer Science) > MNNIT ALLAHABAD > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
