HDU 4990 Reading comprehension
快速幂
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std; long long n,MOD; long long cal(long long a,long long b,long long mod)
{
long long c=;
while(b!=)
{
if(b%==) c=(c*a)%mod,b--;
else a=(a*a)%mod,b=b/;
}
return c;
} int main()
{
while(cin>>n>>MOD)
{
if(n%==)
cout<<(cal(,n+,MOD*)-)/<<endl;
else
cout<<(cal(,n+,MOD*)-)/<<endl;
}
return ;
}
HDU 4990 Reading comprehension的更多相关文章
- HDU - 4990 Reading comprehension 【矩阵快速幂】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4990 题意 初始的ans = 0 给出 n, m for i in 1 -> n 如果 i 为奇 ...
- hdu 4990 Reading comprehension(等比数列法)
题目链接:pid=4990" style="color:rgb(255,153,0); text-decoration:none; font-family:Arial; line- ...
- hdu 4990 Reading comprehension 二分 + 快速幂
Description Read the program below carefully then answer the question. #pragma comment(linker, " ...
- HDU 4990 Reading comprehension(矩阵快速幂)题解
思路: 如图找到推导公式,然后一通乱搞就好了 要开long long,否则红橙作伴 代码: #include<set> #include<cstring> #include&l ...
- HDU 4990 Reading comprehension 简单矩阵快速幂
Problem Description Read the program below carefully then answer the question.#pragma comment(linker ...
- HDU 4990 Reading comprehension 矩阵快速幂
题意: 给出一个序列, \(f_n=\left\{\begin{matrix} 2f_{n-1}+1, n \, mod \, 2=1\\ 2f_{n-1}, n \, mod \, 2=0 \end ...
- hdu-4990 Reading comprehension(快速幂+乘法逆元)
题目链接: Reading comprehension Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- 论文选读二:Multi-Passage Machine Reading Comprehension with Cross-Passage Answer Verification
论文选读二:Multi-Passage Machine Reading Comprehension with Cross-Passage Answer Verification 目前,阅读理解通常会给出 ...
- Attention-over-Attention Neural Networks for Reading Comprehension论文总结
Attention-over-Attention Neural Networks for Reading Comprehension 论文地址:https://arxiv.org/pdf/1607.0 ...
随机推荐
- C#异步的世界【上】
新进阶的程序员可能对async.await用得比较多,却对之前的异步了解甚少.本人就是此类,因此打算回顾学习下异步的进化史. 本文主要是回顾async异步模式之前的异步,下篇文章再来重点分析async ...
- python3.5学习之路_day1_login
登录程序1.输入用户名密码2.认证成功后显示欢迎信息3.输错三次后锁定 #!/usr/bin/env python #_*_coding:utf-8_*_ #by anthor zhangxiaoyu ...
- Asio C++ Library,libuv - Cross-platform asynchronous I/O
http://think-async.com/ http://libuv.org/ https://github.com/libuv/libuv
- eclipse安装
1.下载破解版本 地址:http://www.oyksoft.com/soft/1250.html 2.解压下载包,直接运行eclipse.exe 3.安装过程中如果遇到问题 1).如果遇到erro ...
- js遍历数组对象和非数组对象
//---------for用来遍历数组对象 var i,myArr = ["a","b","c"]; ; i < myArr.len ...
- input的placeholder字体大小无法修改?
链接如下 其实chrome是有这个东西的,那就是shadow DOM. 什么是Shadow-Dom?Shadow DOM是指浏览器的一种能力,它允许在文档(document)渲染时插入一棵DOM元素子 ...
- android 沉浸式状态栏的实现
本文介绍一种简单的实现沉浸式状态栏的方法,要高于或等于api19才可以. 实现android沉浸式状态栏很简单,添加代码两步就可以搞定. 一.在activity中添加 getWindow().addF ...
- centos 6.5 安装mysql 5.6错误
yum list libaio yum install libaio.i686 yum list glibc* yum install glibc.i686 yum list libstdc++* y ...
- openstack私有云布署实践【16.3 Windows Server2008 R2 只有C盘分区镜像制作】
之所以要只有C盘分区镜像,是因为在创建VM或者调整云主机的硬盘大小时,它能自动扩容.无需人工介入 参考http://www.iyunv.com/thread-45149-1-1.html的灵感 ...
- CodeForces 645D Robot Rapping Results Report
二分,拓扑排序. 二分答案,然后进行拓扑排序检查,若某次发现存在两个或者两个以上入度为$0$的节点,那么不可行. #pragma comment(linker, "/STACK:102400 ...