Mathematician QSC
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 275 Accepted Submission(s): 142
Problem Description
QSC dream of becoming a mathematician, he believes that everything in this world has a mathematical law.
Through unremitting efforts, one day he finally found the QSC sequence, it is a very magical sequence, can be calculated bya series of calculations to predict the results ofa course ofa semester ofa student.
This sequence is such like that, firstof all,f(0)=0,f(1)=1,f(n)=f(n−2)+2∗f(n−1)(n≥2)Then the definition ofthe QSC sequence is g(n)=∑ni=0f(i)2. If we know the birthday ofthe student is n, the year atthe beginning ofthe semester is y, the course number x andthe course total score s, thenthe forecast mark is xg(n∗y)%(s+1).
QSC sequence published caused a sensation, afteranumberof students to find out the results ofthe prediction is very accurate, the shortcoming is the complex calculation. As clever as you are, can you writea program to predict the mark?
Input
First line is aninteger T(1≤T≤1000).
The next T lines were given n, y, x, s, respectively.
n、x is 8 bits decimal integer, for example, 00001234.
y is 4 bits decimal integer, for example, 1234.
n、x、y are not negetive.
1≤s≤100000000
Output
For each test casethe output is only oneintegernumber ans inaline.
Sample Input
22016083020161234567866620101010201403030303333
Sample Output
1317
Source
2016 ACM/ICPC Asia Regional Shenyang Online