QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#14373. Recursive sequence

الإحصائيات

Farmer John like to play mathematics games with his $N$ cows. Recently, they are attracted by recursive sequence. In each turn, the cows would stand in a line, while John write two positive numbers $a$ and $b$ on a blackboard. And then, the cows would say their identity number one by one. The first cow says $a$ and the second says $b$. After that, the $i$-th cow says the sum of twice as the second last number, the last number, and $i^4$.

Now, you need to write a program to calculate the number of the $N$-th cow in order to check if John's cows can make it right.

Input format

The first line of input contains an integer $t$, the number of test cases. $t$ test cases follow.

Each case contains only one line with three numbers $N$, $a$ and $b$ ($N, a, b < 2^{31}$) as described above.

Output format

For each test case, output the number of the $N$-th cow. This number might be very large, so you need to output it modulo $2147493647$.

Sample input:

2
3 1 2
4 1 10

Sample output:

85
369

Sample explanation

In the first case, the third number is $85 = 2 * 1 + 2 + 3^4$.

In the second case, the third number is $93 = 2 * 1 + 1 * 10 + 3^4$ and the fourth number is $369 = 2 * 10 + 93 + 4^4$.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.