0% found this document useful (0 votes)
78 views5 pages

WWW Spoj Com Problems PIBO

The document describes a problem involving calculating the value of a sequence Pib(n) where Pib(n) is equal to the Fibonacci sequence plus a polynomial P(n). The input provides the values of n and the coefficients of P(n), and the output is the value of Pib(n) modulo 1,111,111,111. Examples are given calculating Pib(n) for different polynomials.

Uploaded by

Ashish Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views5 pages

WWW Spoj Com Problems PIBO

The document describes a problem involving calculating the value of a sequence Pib(n) where Pib(n) is equal to the Fibonacci sequence plus a polynomial P(n). The input provides the values of n and the coefficients of P(n), and the output is the value of Pib(n) modulo 1,111,111,111. Examples are given calculating Pib(n) for different polynomials.

Uploaded by

Ashish Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PROBLEMS

STATUS

RANKS

DISCUSS

Problems / classical / Fibonacci vs Polynomial

JOBS

sign in

Status

Ranking

PIBO - Fibonacci vs Polynomial


no tags
Define a sequence Pib(n) as following
Pib(0) = 1
Pib(1) = 1
otherwise, Pib(n) = Pib(n-1) + Pib(n-2) + P(n)
Here P is a polynomial.
Given n and P, find Pib(n) modulo 1,111,111,111.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Input
First line of input contains two integer n and d (0 n 109, 0 d 100), d is the degree
of polynomial.
The second line contains d+1 integers c0,c1 cd, represent the coefficient of the
polynomial(Thus P(x) can be written as cixi). 0 ci 100 and cd 0 unless d = 0.

Output
A single integer represents the answer.

Example
Input:
10 0
0
Output:
89
Input:
10 0
1
Output:
177
Input:
100 1
1 1
Output:
343742333

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Submit solution!

hide comments
Problem Solver:

2011-11-12 01:16:02

Oh, yes, sorry for that


Miguel Oliveira: 2011-11-12 01:07:38
The answer is 89. Note that Pib(n) is not the same as the Fibonacci sequence as
Pib(0)=1 while Fib(0)=0
Basically, without the polynomial Pib(n) = Fib(n+1)
Problem Solver:

2011-11-12 00:35:25

Hey @Bin Jin


Very nice problem, but i have a question
shouldn't in first testcase answer be 55 ?
Because 89 is 11th fibonacci number and we have given n=10
Not a big difference, just saying. Cheers

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Submit solution!
Added by:
Date:
Time limit:
Source limit:
Memory limit:
Cluster:
Languages:

open in browser PRO version

Bin Jin
2011-11-11
1s
10240B
1536MB
Cube (Intel Pentium G860
3GHz)
All except: C++ 5

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

About | Tutorial | Tools | Clusters | Credits | Jobs | API


RSS
Spoj.com. All Rights Reserved. Spoj uses Sphere Engine by Sphere Research Labs.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

You might also like