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

How to slove it fast..........
Posted by tbtbtb 27 Apr 2004 15:00
Re: How to slove it fast..........
Posted by Gheorghe Stefan 4 May 2004 16:15
you can generate all result with a rate of
But I think it very large and seems no disciplinarians
Posted by Zhang Jin Jing 5 May 2004 14:41
Re: But I think it very large and seems no disciplinarians
Posted by Gheorghe Stefan 7 May 2004 14:55
you generate all values for 1 million, 2 millions and so on. You have only 1000 values. Then you only sweep the interval from previous checkpoint to N.
Re: But I think it very large and seems no disciplinarians
Posted by hello 30 May 2004 19:41
I'm puzzled.
I don't understand your way.
How to get 2 millions values from 1 million ?
Re: But I think it very large and seems no disciplinarians
Posted by Vlad Veselov 31 May 2004 17:18
You write a stupid program, which calculates values for all n and writes to file values for n = k * 10^6, where k is positive integer. Then you wait few minutes (hours,days...), while your program generates result. You make array of constants, where i-th value is f(n) for n = i * 10^6. When your program gets the value of n it finds k such that k * 10^6 <= n and (k + 1) * 10^6 > n and calculates values f(k*10^6+1),...,f(n).
Re: But I think it very large and seems no disciplinarians
Posted by hello 31 May 2004 23:03
Oh. Thank you very much !!!
But I don't think it is a very good way .
Do you know the better way ?
No one knows the better way
Posted by Vlad Veselov 1 Jun 2004 16:30
Re: No one knows the better way
Posted by hello 1 Jun 2004 20:04
Oh. Thank you very much !!!
Your way is good .
I got AC just use 0.062s.
But I spend much time on making the answer of 1 , 2 , 3... millions.

Edited by author 01.06.2004 20:04
No subject
Posted by Gheorghe Stefan 3 Jun 2004 19:26
you can generate a value in O(N) time so for 1 billion, the maximum value, the program must run few seconds... mine worked in 10-15...
Re: No subject
Posted by Pasha 22 Jul 2004 16:15
Gheorghe Stefan wrote 3 June 2004 19:26
you can generate a value in O(N) time so for 1 billion, the maximum value, the program must run few seconds... mine worked in 10-15...
Why must you calculate this for 1 billion? In the problem clearely said: n from 0 to 100,000,000!
Thanks to Vlad Veselov! I've got AC!
Re: No subject
Posted by Gheorghe Stefan 23 Jul 2004 01:03
so I was mistaken, it was only 100 mil... so what?
big deal...
I have a best way to do it !
Posted by N.M.Hieu ( DHSP ) 11 Jul 2005 22:04
It belongs my friend ! He came from China ! His solution is O(10000) in the worst case ! I haven't understood him yet ! So I will write there to everybody ! If someone understand , please explain for me !

Here the solution :

Suppose f(1)=a1*f(0)+b1 (mod 9973), then f(9973*i+1)==a1*f(9973*i)+b1 (mod 9973).

So after calculating the (a,b) in f(9973)=a*f(0)+b (mod 9973), then f(9973*(i+1))=a*f(9973)+b (mod 9973)

So we can get the algorithm with O(10000) in time.