快速幂

#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的更多相关文章

  1. HDU - 4990 Reading comprehension 【矩阵快速幂】

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4990 题意 初始的ans = 0 给出 n, m for i in 1 -> n 如果 i 为奇 ...

  2. hdu 4990 Reading comprehension(等比数列法)

    题目链接:pid=4990" style="color:rgb(255,153,0); text-decoration:none; font-family:Arial; line- ...

  3. hdu 4990 Reading comprehension 二分 + 快速幂

    Description Read the program below carefully then answer the question. #pragma comment(linker, " ...

  4. HDU 4990 Reading comprehension(矩阵快速幂)题解

    思路: 如图找到推导公式,然后一通乱搞就好了 要开long long,否则红橙作伴 代码: #include<set> #include<cstring> #include&l ...

  5. HDU 4990 Reading comprehension 简单矩阵快速幂

    Problem Description Read the program below carefully then answer the question.#pragma comment(linker ...

  6. 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 ...

  7. hdu-4990 Reading comprehension(快速幂+乘法逆元)

    题目链接: Reading comprehension Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 32768/32768 K ( ...

  8. 论文选读二:Multi-Passage Machine Reading Comprehension with Cross-Passage Answer Verification

    论文选读二:Multi-Passage Machine Reading Comprehension with Cross-Passage Answer Verification 目前,阅读理解通常会给出 ...

  9. Attention-over-Attention Neural Networks for Reading Comprehension论文总结

    Attention-over-Attention Neural Networks for Reading Comprehension 论文地址:https://arxiv.org/pdf/1607.0 ...

随机推荐

  1. C语言之冒泡排序

    冒泡排序: 1). 简介 其实就是把一个数组的元素,按照从小到大(从大到小)得顺序,重新排列起来,这种排序就叫冒泡排序 例: int nums[5] = {5,4,3,2,1}; //经过排序后 下标 ...

  2. C#微信公众号开发--网页授权(oauth2.0)获取用户基本信息二

    前言 这一篇实现snsapi_userinfo,写这篇时其实我是有疑惑的,因为我并没有调试成功,但是我反复检查程序和思路是没有问题的,因为我使用的测试公众号,群里一个伙计说他之前调试时用的也是测试公众 ...

  3. python之路 - 基础4

    1.函数非固定参数 *args *kwargs def test(*args): print (args) test(1,2,3,4,5) test(*[1,2,3,4,5]) #*args = *[ ...

  4. 51nod1279(二分)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1279 题意:中文题诶- 思路: 就想短板效应一样,很显然决定 ...

  5. 记一次Debian下PHP环境的搭建(nginx+mariadb+PHP)!

    顺序是先安装nginx,然后安装mariadb,最后安装PHP.系统用的是debian7 安装nginx sudo apt-get install nginx 我这里用的是稳定的源,没用测试的源,所以 ...

  6. [Bzoj]1012最大数maxnumber

    题目如上(线段树???),蒟蒻第二眼想法(其实这道题正解是单队的说,但蒟蒻刚学线段树,于是...就) 献上黑历史: RE是因为蒟蒻数组开太小:第一次开110000:第二次开200000:结果就………… ...

  7. linux看代码方法和建议

    http://blog.csdn.net/lxl584685501/article/details/46803077

  8. on事件绑定阻止冒泡的问题

    当使用on进行事件绑定时当要给document绑定click,而子元素要禁止冒泡,那么子元素里面的子元素的click事件就会无效了, 下面无效版: $('#queue').on('click', '. ...

  9. Linux下常用的压缩与解压命令

    .tar (注:tar是打包,不是压缩!) 解包: tar xvf FileName.tar 打包: tar cvf FileName.tar DirName .gz 解压1: gunzip File ...

  10. [SQL基础教程] 2-2 算数运算符和比较运算符

    [SQL基础教程] 2-2 算数运算符和比较运算符 算数运算符 四则运算 运算符 含义 + - * / SELECT col_1*2 AS col_new FROM table; 注意 所有包含NUL ...