2013 ACM-ICPC长沙赛区全国邀请赛So Easy! && 2015 ACM/ICPC Asia Regional Shenyang Online-Best Solver
来源:互联网 发布:远程协助软件steam 编辑:程序博客网 时间:2024/06/02 14:08
<span style="background-color: transparent; color: rgb(124, 169, 237); font-family: Arial; font-size: 18px;">So Easy!</span>
A sequence Sn is defined as:
Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate Sn.
You, a top coder, say: So easy!
Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate Sn.
You, a top coder, say: So easy!
Input
There are several test cases, each test case in one line contains four positive integers: a, b, n, m. Where 0< a, m < 215, (a-1)2< b < a2, 0 < b, n < 231.The input will finish with the end of file.
Output
For each the case, output an integer Sn.
Sample Input
2 3 1 20132 3 2 20132 2 1 2013
Sample Output
4144
4
那么用矩阵快速幂就可以了,代码如下:
Best Solver
Problem Description
The so-called best problem solver can easily solve this problem, with his/her childhood sweetheart.
It is known thaty=(5+26√)1+2x .
For a given integerx (0≤x<232) and a given prime number M (M≤46337) , print [y]%M . ([y] means the integer part of y )
It is known that
For a given integer
Input
An integer T (1<T≤1000) , indicating there are T test cases.
Following areT lines, each containing two integers x and M , as introduced above.
Following are
Output
The output contains exactly T lines.
Each line contains an integer representing[y]%M .
Each line contains an integer representing
Sample Input
70 463371 463373 463371 4633721 46337321 463374321 46337
Sample Output
Case #1: 97Case #2: 969Case #3: 16537Case #4: 969Case #5: 40453Case #6: 10211Case #7: 17947
此题的a、b完全满足上题的要求,可用与上题完全相同的思路求解,唯一的不同点即为时向下取整而非向上取整,那么,在上题的答案基础上,减一,就是此题的答案。
还有就是指数太大,要找到循环节,其实由于mod小,循环节并没有太大,是可以搞的。
0 0
- 2013 ACM-ICPC长沙赛区全国邀请赛So Easy! && 2015 ACM/ICPC Asia Regional Shenyang Online-Best Solver
- 2015 ACM/ICPC Asia Regional Shenyang Online
- 2015 ACM/ICPC Asia Regional Shenyang Online
- 2015 ACM/ICPC Asia Regional Shenyang Online
- 2015 ACM/ICPC Asia Regional Shenyang Online
- 2015 ACM/ICPC Asia Regional Shenyang Online
- HDU 4565 -- So Easy! 数学 && 2013 ACM-ICPC 长沙赛区全国邀请赛 A题
- hdu 4565 So Easy! /2013 ACM-ICPC 长沙赛区全国邀请赛A题 矩阵乘法
- 2016 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional Shenyang Online
- 2017 ACM/ICPC Asia Regional shenyang Online
- HDU 4565 So Easy!(思想+矩阵快速幂)——2013 ACM-ICPC长沙赛区全国邀请赛
- Jpype的使用
- mongodb中如何创建数据库
- 由微信推送引发的SQL join语句总结,顺便复习一下下MySQL
- 【总述】软件工程
- 异常
- 2013 ACM-ICPC长沙赛区全国邀请赛So Easy! && 2015 ACM/ICPC Asia Regional Shenyang Online-Best Solver
- 开启Java之路——不走弯路,就是捷径,欲速则不达
- Week2
- 只有坚持,坚持,在坚持,才能取得最后的成功
- POJ1611 && POJ2524 并查集入门
- Week Four_the last one
- JAVA阶段以及收银系统项目总结
- JAVA阶段以及收银系统项目总结
- Android初中级阶段——一个新的开始,新的起点