Hdu-2817-a sequence of numbers (Quick power modulo!) )

Source: Internet
Author: User

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!) )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.