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 1108. Heritage

please give me any trick for multiplying bignum ! i got tl and why solution for a(n) is...
Posted by TheBlaNK 16 Apr 2002 15:27
please give me any trick for multiplying bignum ! i got tl and why
solution for a(n) is...

a(n)=pow(a(n-1),2)-a(n-1)+1;
Mhm....(+)
Posted by Miguel Angel 17 Apr 2002 01:29
a(n)= a(n-1)^2-a(n-1) + 1

the way to do the problem is very easy, you see, the first fraction
is obviusly the least which is 1/2 then you may want a fraction which
is less than this last one but added with this leads to minimum left,
so you may want a fraction the more likely to 1/2, this is 1/3 (2+1),
then with this to add a third fraction, this will be 1/2 + 1/3 + ?,
could be 1/6, but this leads to get a sum of 1, so the next will be
1/7 (2*3 + 1), the next will be 1/43 (2*3*7 + 1), the formula you put
is a pretty factorization of this.
There's a method to do multiplications on O(n^1.54), but i don't know
how to do it exactly, you may want to see it in a book.
Good Luck :)
Miguel Angel.
miguelangelhdz@hotmail.com
Re: Mhm....(+)
Posted by Vlad Ionescu 2 Jul 2003 21:33
An easyier way to get AC is to represent the bignums in base 1000.
There is a lot of time saving an the modifications needed to be done
when writing the output are easy (just add some 0s if a[j]<100 and a
[j]<10).
As for the O(N^1.58) algo, you were supposed to split the numbers
into two halfs: A=C*10^n/2+D and B=E*10^n/2+F.
G=(C+D)*(E+F)=C*E+D*F+C*F+D*E
Then A*B=C*E*10^n+(G-C*E-D*F)*10^n/2+D*F
We only hav to do 3 multiplications instead of 4 (G,C*E,D*F). In
order to do these multiplication we use the same algorithm, until
C,E,D,F on have one digit.