HDU - 4704 sum 大数取余+欧拉降幂
Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 3980 Accepted Submission(s): 1620

1. For N = 2, S(1) = S(2) = 1.
2. The input file consists of multiple test cases.
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define MAX 1000005
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std; typedef long long ll; ll qMod(ll a,ll b){
ll ans=;
while(b>){
if(b&) ans=ans*a%MOD;
b>>=;
a=a*a%MOD;
}
return ans;
}
int main()
{
int n,len,i;
char s[MAX];
while(~scanf(" %s",s)){
ll c=;
len=strlen(s);
for(i=;i<len;i++){
int x=s[i]-'';
c=c*+x;
if(c>) c%=;
}
c=((c-)%+)%;
printf("%lld\n",qMod(,c));
}
return ;
}
HDU - 4704 sum 大数取余+欧拉降幂的更多相关文章
- 2019计蒜之道初赛3 D. 阿里巴巴协助征战SARS(困难)(大数取余+欧拉降幂)
阿里巴巴协助征战SARS(困难) 33.29% 1000ms 262144K 目前,SARS 病毒的研究在世界范围内进行,经科学家研究发现,该病毒及其变种的 DNA 的一条单链中,胞嘧啶.腺嘧啶均 ...
- hdu 1226 bfs+余数判重+大数取余
题目: 超级密码 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- 1214 - Large Division -- LightOj(大数取余)
http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...
- POJ2635The Embarrassed Cryptographer(大数取余+素数筛选+好题)
题目链接 题意:K是由两个素数乘积,如果最小的素数小于L,输出BAD最小的素数,否则输出GOOD 分析 素数打表将 L 大点的素数打出来,一定要比L大,然后就开始枚举,只需K对 素数 取余 看看是否为 ...
- java大数取余
java大数取余: 类方法:BigInteger.divideAndRemainder() 返回一个数组,key = 0为商key = 1为余数 import java.util.*; import ...
- HDU 2814 斐波那契循环节 欧拉降幂
一看就是欧拉降幂,问题是怎么求$fib(a^b)$,C给的那么小显然还是要找循环节.数据范围出的很那啥..unsigned long long注意用防爆的乘法 /** @Date : 2017-09- ...
- Codeforces Round #279 (Div. 2) C. Hacking Cypher (大数取余)
题目链接 C. Hacking Cyphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...
- 题解报告:hdu 4704 Sum(扩展欧拉定理)
Problem Description Sample Input 2 Sample Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The input ...
- Sum(欧拉降幂+快速幂)
Input 2 Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The input file consists of multiple test cas ...
随机推荐
- 配置springMVC时出现的问题
配置springMVC时出现的问题 项目结构如图:
- 无法远程访问 MySql Server
改表法.可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "use ...
- jQuery学习笔记(7)--表格展开关闭
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...
- 马尔科夫链在第n步转移的状态的概率分布
- python mmap使用记录
1.写文件 with open('??', 'r+b') as f: with contextlib.closing(mmap.mmap(f.fileno(), size, flags=mmap.MA ...
- PAT 天梯赛 L2-022. 重排链表 【数据结构】
题目链接 https://www.patest.cn/contests/gplt/L2-022 思路 先用结构体 把每个结点信息保存下来 然后深搜一下 遍历一下整个链表 然后就重新排一下 但是要注意一 ...
- ubuntu16.04下安装wordpress
安装过程 http://blog.topspeedsnail.com/archives/4635 http://blog.topspeedsnail.com/archives/4646 碰到的问题 1 ...
- HAOI 2017 游记
省选 2017年4月23日 流水账式游记,不喜勿喷. Day0: 准备出发,上午敲了一顿板子,板子敲完了就打小游戏,老师也不管了. 过程中各种奶,说什么今年一定考仙人掌啦,今年一定考字符串啦,今年一定 ...
- i=i+2 与i+=2
i=i+2 比 i+=2多了一次对变量 i 的运算.后者效率高
- Windows Server 2008 MS Office 操作 检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件失败,原因是出现以下错误: 80070005 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))。
Make sure that you have Office runtime installed on the server. If you are using Windows Server 2008 ...