We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #120: Square remainders
Project Euler #120: Square remainders
Sort by
recency
|
6 Discussions
|
Please Login in order to post a comment
After figuring out (which is the most difficult part IMHO) the maximum remainder for a particular and , taking special care of , , we can obtain an solution making use of the formula of sum of cubes , sum of squares and sum of consecutive integers .
I was unable to formally express how the maximum remainder can be found, and I suppose it would somehow begin with if is even and if is odd, and that any terms having as its factor could be ignored (therefore only look at the last or the last two terms depending on ), so we can pick that is best for what we want. The way I did it was to brute force some input and guess the pattern, though.
I believe you should be looking at:
What is the value of n takein in the problem? Its not mentioned anywhere except explanation of one example. Please help.
Pretty sure I found the pattern for the maximum remainder sum for a given 'a.' (for even a, this should be a^2-2*a, for odd a, this should be a^2-a).
When I put this in sigma notation, I was able to get a closed formed solution 1/24(8A^3-6A^2-20A)+2 (the 2 I added when I saw that I was neglecting to add the first case with a=2, e=2).
I also found the multiplicative inverse of 24 modulo (10^9+7) so this computation can be performed quickly.
I put in a snippet of my code below (for A even with e=2). The rest are similar so I imagine the issue will come up below. I got the test cases 1 and 2 working, but the rest give wrong answers.
Any sort of helpful hint would be greatly appreciated.
}
what value should n take in the problem? i can't understand it from the problem description need help
what value should n take in the problem? i can't understand it from the problem description need help