question link:- http://www.spoj.com/problems/FACTMUL/
link to my solution:- http://ideone.com/U97WEX
What’s wrong with my code?Pls someone help
hello raul1rnjn535_3
first of all i would like to mention if you are running your loop n times then there i no benefit of finding factors of the given mod. for each value of n >= 587117 answer is zero ok .
i myself was not able to get AC for this problem in CPP but when i submitted the same code in python it got accepted.
checkout both of these solution i think you will get what you are looking for…
both code are exactly same.
http://ideone.com/gY14OD cpp code WA
http://ideone.com/VILk12 python code AC
@ma5termind…even I knew the soln in Python but I wanted to solve it in C…I think there is an overflow after n=11.Since Python has a very large size of int overflow does not occur but that is not the case with C/C++…u may chek yrself…thanx anyways for yr reply…
yes you are right even i was astonished why same solution in cpp giving me wrong answer but there are some accepted solution in CPP. but no problem i will try it again then respond you
A bigger version of the same problem is also available on SPOJ
here it is :: it will amazed you.
The accepted solutions prompted me to try it in cpp/c…
hmm do comment here if you are able to get AC with the cpp code
to read about bit manipulation read from topcoder there is a tutorial over this topic
It is actually pretty easy.
Run a loop till sqrt(MOD). Find it’s biggest factor i.e 587117.
Thus any factorial of number >= 587117 will be 0 when done modulo the given number in the question.