Snow Leopard and ranks of contests
All submissions for this problem are available.
Snow Leopard has proposed an algorithm for calculating rating of the contestant on codechef. The algorithm can be described as follow:
The rating for the first time and second time paritcipation is fixed for the contestant. Rating for the next participation onwards will depend on previous two ratings. The dependecies is such that the rating for the current participation is c(integer) more than n(integer) times last participation plus m(integer) times last to last participation.
First line of the input contains n, m, c, f1, f2, q, where f1 and f2 are the first two ratings of the contestant , q is the number of queries to be processed and m, n, c are as described above. Following q lines will contain an integer x.
For each query you should output the xth rating for the contestent %1000000007 .
- 1<= q <=100000
- f1, f2, c, n , m <=100000
- 3 <= x<= 10^16
Input: 1 2 3 4 5 1
3 Output: 16
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.