ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1309. Dispute

number size is more then 64 bit
Posted by Anushavan Azatyan 9 Oct 2015 17:30
If I enter for example 150000 I get overflow , (y-1)x^5 passes limitation of any type.

Do I need to create new type to keep ((10^8)^5)size value ?
Or anything else I have to do with values, expression?
Re: number size is more then 64 bit
Posted by Mahilewets 22 Jul 2017 21:22
I solved it with that g-function.

int g(int x, int y, long long m=9973){
    long long lx=x, ly=y, lx2=(lx*lx)%m, lx3=(lx*lx2)%m, lx5=(lx2*lx3)%m;

    return ( ((ly-1)*lx5)%m + lx3 - (lx*ly)%m + (3*lx)%m + (7*ly)%m) % m;
}