A sequence of numbersTime
limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 3494 Accepted Submission (s): 1073
Problem DESCRIPTIONXINLV wrote some sequences on the paper a long time ago, they might be arithmetic or geometric sequence S. The numbers is not very clear now, and only the first three numbers of each sequence is recognizable. XINLV wants to know some numbers in these sequences, and he needs your help.
Inputthe first line contains a integer n, indicting that there is n sequences. Each of the following N lines contain four integers. The first three indicating the first three numbers of the sequence, and the last one are K, indicating that we want to know The k-th numbers of the sequence.
You can assume 0 < K <= 10^9, and the other three numbers is in the range [0, 2^63]. All the numbers of the sequences is integers. And the sequences are non-decreasing.
Outputoutput one line for each test case, which is, the k-th number module (%) 200907.
Sample Input
21 2 3 51 2 4 5
Sample Output
516
Source2009 multi-university Training Contest 1-host by Tju
Test instructions: is to give the first three number of columns, to determine whether it is a linear or equal, and then calculate the number of K, pay attention to calculate the time to use a fast power to take the mold (also pay attention to overflow problem, it is best to use long long, I did not notice WA two times%>_<%)
arithmetic or geometric sequences. Arithmetic progression or geometric series
AC Code:
Hdu-2817-a sequence of numbers (Quick power modulo!) )