当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5667:Sequence

题目描述
$\ \ \ \ $Holion August will eat every thing he has found.

$\ \ \ \ $Now there are many foods,but he does not want to eat all of them at once,so he find a sequence.

$f_n=\left\{\begin{matrix}
1 ,&n=1 \\
a^b,&n=2 \\
a^bf_{n-1}^cf_{n-2},&otherwise
\end{matrix}\right.$

$\ \ \ \ $He gives you 5 numbers n,a,b,c,p,and he will eat $f_n$ foods.But there are only p foods,so you should tell him $f_n$ mod p.
输入解释
$\ \ \ \ $The first line has a number,T,means testcase.

$\ \ \ \ $Each testcase has 5 numbers,including n,a,b,c,p in a line.

$\ \ \ \ 1\le T \le 10,1\le n\le 10^{18},1\le a,b,c\le 10^9$,$p$ is a prime number,and $p\le 10^9+7$.
输出解释
$\ \ \ \ $Output one number for each case,which is $f_n$ mod p.
输入样例
1
5 3 3 3 233
输出样例
190
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #80

源链接: HDU-5667

最后修改于 2020-10-25T23:24:39+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)