|
|
вернуться в форумA question... Послано Alexey 27 июн 2006 15:46 g(x,y)=((y-1)*x^5+x^3+3*x-x*y+7*y) mod M The result is in 0..M-1 But while counting it I have problems with type. How to make it work with big values (For expample, If x=1000000)? Thanks. Re: A question... Послано Sid 27 июн 2006 17:35 Everybody knows... x*x mod m = ((x mod m) * (x mod m))mod m x+x mod m = ((x mod m) + (x mod m))mod m Yeah, but... Послано Alexey 27 июн 2006 17:58 You mean that ((y-1)*x^5) mod M=(((y-1) mod M)*(x mod M)^5) mod M. But x mod M can be 9972 (M=9973) and 9972^5 has 14 digits. It's too much. I know another formula... (x^y) mod M=((((x mod M)*x) mod M)*x) Mod M... y times. But it gets incorrect answer... Can U give me answers for these tests? 1) 9973 2) 19946 3) 29919 4) 8 Thanks. Edited by author 27.06.2006 18:49 |
|
|