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 1528. Sequence

A fast algo?
Posted by ONU_1785 10 Dec 2011 05:54
I got AC with 0.734s:



Who can tell some hints to make it work faster?


Edited by author 08.05.2012 14:47

Edited by author 08.05.2012 14:47
Re: A fast algo?
Posted by Dmitriy Black 2 Jan 2012 03:36
You should minimize the number of mod operations. for example when I use mod each iteration i got 0.9 sec. But when I minimized the number of mod operations I got 0.56 sec. You should use long f(java) and calculate (f mod p) when f > 10^14, but not each time you calculate your f.