日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > HDU 5895 Mathematician QSC(逆元應用+矩陣快速冪+數論知識)——2016 ACM/ICPC Asia Regional Shenyang Online

HDU 5895 Mathematician QSC(逆元應用+矩陣快速冪+數論知識)——2016 ACM/ICPC Asia Regional Shenyang Online

來源:程序員人生   發布時間:2017-01-09 11:36:26 閱讀次數:2844次

傳送門

Mathematician QSC

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 208    Accepted Submission(s): 101


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 by a series of calculations to predict the results of a course of a semester of a student.

This sequence is such like that, first of all,f(0)=0,f(1)=1,f(n)=f(n?2)+2?f(n?1)(n2)Then the definition of the QSC sequence is g(n)=ni=0f(i)2. If we know the birthday of the student is n, the year at the beginning of the semester is y, the course number x and the course total score s, then the forecast mark is xg(n?y)%(s+1).
QSC sequence published caused a sensation, after a number of students to find out the results of the prediction is very accurate, the shortcoming is the complex calculation. As clever as you are, can you write a program to predict the mark?
 

Input
First line is an integer 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 case the output is only one integer number ans in a line.
 

Sample Input
2
20160830 2016 12345678 666
20101010 2014 03030303 333
 

Sample Output
1
317

題目大意:

首先定義了1個 f() 函數,f(n)=2?f(n?1)+f(n?2),f(1)=1,f(0)=0, 然后又定義了1個 g() 函數 , g(n)=ni=0f(i)2,

最后讓你求的是 xg(n?y)%(s+1), 其中 x,y,n,s 都是輸入的。

解題思路:
這個題目其實不是很難,仔細分析1下還是挺簡單的,首先我們1看到這個 f() 函數的表達式,1定會聯想到矩陣快速冪,那末我們首先將 f(n)

能夠通過矩陣快速冪得到,具體怎樣得到的呢,我現在來講1下:

首先,我們設1個矩陣 A ,這就是那個轉移的矩陣,也就是說需要構造1個矩陣 A 使得 (f(n?2),f(n?1))?A=(f(n?1),f(n)) 成立,那末現在 A

1定是1個 2?2 的矩陣,然后在根據 f(n) 的遞推式得到 A 矩陣中的具體值,算出來是:
0112

然后再來分析我們要求的式子: xg(n?y)%(s+1),如果滿足 g(n?y)Phi(s+1) 的時候我們可以將其轉化為

xg(x?y)%Phi(s+1)+Phi(s+1)%(s+1)(1) ,否則只能暴力計算,然后我們發現只有當 n?y11 的時候才暴力計算也很簡單了,直接求,

然后快速冪就ok了,關鍵是解決上面 (1) 式的那個問題,首先我們看1下 g(n) 能不能寫成關于 f() 的比較簡單的式子,然后我們將其展開發現

f(i)?f(i+1) 有關系,那末 f(i)?f(i+1) 等于甚么呢:

f

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 久久视频一区 | 亚洲天堂偷拍 | 国产精品久久久久久久久免费软件 | 国产精品无码久久久久 | 欧美在线观看一区 | 五月婷婷在线观看 | 日韩精品第一页 | 91看污| 黄色片播放视频 | 久久久亚洲一区 | 亚洲一区二区高清 | 午夜精品久久 | 99久久99 | 欧美a网站| 国产激情视频在线 | 69视频免费在线观看 | 国产成人av一区二区三区在线观看 | 日韩国产一区二区 | 成人在线观 | 国产精品国产三级国产在线观看 | 在线久久| 久久韩日 | 日韩精品免费一区二区三区 | 亚洲一区在线免费观看 | 国产精品久久久久久久久久免费看 | 国产三级电影在线观看 | 成人午夜精品 | 欧美一二三 | 久久久国产精品视频 | 国产高清一级毛片在线不卡 | 国产一区二| 日本精品一区二区三区视频 | 欧美精品免费在线观看 | 亚洲成人精品一区 | 黄色一级片在线 | 日本欧美中文字幕 | 伊人成综合 | 日韩欧美在线一区二区 | 性视频在线播放 | 久久精品久久久 | 国产97人人超碰caoprom |