Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A word of caution: In the case c=2, len1=1, len2=2, the answer will be the N'th Fibonacci number, and the Fibonacci numbers grow (approximately) exponentially with a growth factor of the golden ratio, phi ~ 1.61803399. For the huge value N=10^15, the answer will be about phi^(10^15), an enormous number. The answer will have storage requirements on the order of (ln(phi^(10^15))/ln(2)) / (8 * 2^40) ~ 79 terabytes. Since you can't even <em>access</em> 79 terabytes in 20 seconds, it's unlikely you can meet the speed requirements in this special case.</p> <p>Your best hope occurs when C is not too large, and leni is large for all i. In such cases, the answer will still grow exponentially with N, but the growth factor may be much smaller.</p> <p>I recommend that you first construct the integer matrix M which will compute the (i+1,..., i+k) terms in your sequence based on the (i, ..., i+k-1) terms. (only row k+1 of this matrix is interesting). Compute the first k entries "by hand", then calculate M^(10^15) based on the repeated squaring trick, and apply it to terms (0...k-1). </p> <p>The (integer) entries of the matrix will grow exponentially, perhaps too fast to handle. If this is the case, do the very same calculation, but modulo p, for several moderate-sized prime numbers p. This will allow you to obtain your answer modulo p, for various p, without using a matrix of bigints. After using enough primes so that you know their product is larger than your answer, you can use the so-called "Chinese remainder theorem" to recover your answer from your mod-p answers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload