焦作网赛-G-欧拉降幂
https://nanti.jisuanke.com/t/31716
答案就是2^(n-1)%mod ,n非常的大,由欧拉降幂公式 AB%C=AB%phi(C)+phi(C)%C 化简
2n-1%mod = 2(n-1)%(mod-1)+(mod-1)%mod
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define inf 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
LL mod=;
LL phi(LL n){
LL ans=n;
for(LL i=;i*i<=n;++i){
if(n%i==){
ans=ans*(i-)/i;
while(n%i==)n/=i;
}
}
if(n>) ans=ans*(n-)/n;
return ans;
}
LL qpow(LL a,LL b,LL c){
if(a==) return a;
LL r=;
while(b){
if(b&)r=r*a%c;
a=a*a%c;
b>>=;
}
return r;
}
char n[];
int main(){
LL t;
scanf("%lld",&t);
while(t--){
scanf("%s",n);
int len=strlen(n);
LL pc=mod-,r=;
for(int i=;i<len;++i){
r=(r*+n[i]-'')%pc;
}
r=(r-+pc)%pc;
r+=pc;
printf("%lld\n",qpow(,r,mod));
}
return ;
}
焦作网赛-G-欧拉降幂的更多相关文章
- 19南京网络赛B 欧拉降幂
题目链接 给a,b,p.有b个a的幂 #include <iostream> using namespace std; typedef long long LL; const LL N = ...
- 2019ICPC网赛南京站B题 super_log(欧拉降幂
https://nanti.jisuanke.com/t/41299 题意:让算a^(a^(a^(...))),一共b个a, (mod p)的结果. 思路:这是个幂塔函数,用欧拉降幂公式递归求解. # ...
- 吉首大学校赛 A SARS病毒 (欧拉降幂)
链接:https://ac.nowcoder.com/acm/contest/925/A来源:牛客网 题目描述 目前,SARS 病毒的研究在世界范围内进行,经科学家研究发现,该病毒及其变种的 DNA ...
- 牛客OI测试赛 F 子序列 组合数学 欧拉降幂公式模板
链接:https://www.nowcoder.com/acm/contest/181/F来源:牛客网 题目描述 给出一个长度为n的序列,你需要计算出所有长度为k的子序列中,除最大最小数之外所有数的乘 ...
- 2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂
2019-ACM-ICPC-南昌区网络赛-H. The Nth Item-特征根法求通项公式+二次剩余+欧拉降幂 [Problem Description] 已知\(f(n)=3\cdot f(n ...
- 吉首大学2019年程序设计竞赛(重现赛)- A SARS病毒 (矩阵,欧拉降幂)
题目链接:https://ac.nowcoder.com/acm/contest/992/A 题意:求出长度为n的字符串个数,字符串由A.C.G.T组成,其中A和C必须成对出现. 思路:我们规定: ...
- 2018牛客网暑期ACM多校训练营(第四场) A - Ternary String - [欧拉降幂公式][扩展欧拉定理]
题目链接:https://www.nowcoder.com/acm/contest/142/A 题目描述 A ternary string is a sequence of digits, where ...
- 牛客网多校第4场 A.Ternary String 【欧拉降幂】
题目:戳这里 学习博客:戳这里 欧拉函数的性质: ① N是不为0的整数.φ(1)=1(唯一和1互质的数就是1本身) ② 除了N=2,φ(N)都是偶数. ③ 小于N且与N互质的所有数的和是φ(n)*n/ ...
- Codeforces Round #536 (Div. 2) F 矩阵快速幂 + bsgs(新坑) + exgcd(新坑) + 欧拉降幂
https://codeforces.com/contest/1106/problem/F 题意 数列公式为\(f_i=(f^{b_1}_{i-1}*f^{b_2}_{i-2}*...*f^{b_k} ...
随机推荐
- Visual Studio 安装easyX且导入graphics库后,outtextxy提示未定义标示符
1.点击 “项目” ,然后点击 “属性”. 2. 然后点击左侧 “配置与属性” 下的 “常规” ,在点击 “字符集” ,选择 “使用多字节字符集” 即可解决问题
- CAS Client集群环境的Session问题及解决方案 不能退出登录
casclient源代码下载链接:https://github.com/apereo/java-cas-client cas官网链接:https://www.apereo.org/projects/c ...
- Lintcode521-Remove Duplicate Numbers in Array-Easy
Description Given an array of integers, remove the duplicate numbers in it. You should: Do it in pla ...
- SAP字段与表的对应关系
SAP字段与表的对应关系 MASTER DATA-主数据 Customer Master KNA1 Customer Basic Data KNB1 ...
- _event_stop
EventId 事件ID TeamId 事件玩家分组,攻守(防守为1,进攻为2),自定义阵营(_faction表自定义阵营ID),公会(公会guid) StopType 结束事件需要满足的条件,枚举类 ...
- Codeforces 746 G. New Roads
题目链接:http://codeforces.com/contest/746/problem/G mamaya,不知道YY了一个什么做法就这样过去了啊 2333 首先我显然可以随便构造出一棵树满足他所 ...
- 安装logstash和logstash-input-jdbc
一.安装logstash 1.mac 下直接 brew install logstash 二.安装logstash-input-jdbc 直接在logstash的安装目录bin下运行 ./logsta ...
- Swing使用Substance外观包异常问题
问题一: 今天更新我的Java版QQ,在网上找到了Substance外观包,效果不错,直接用了,可是设置水印问题时就出现问题,网上有现成的例子 JFrame.setDefaultLookAndFeel ...
- python 安装包
一般python的包都是.tar.gz结尾的压缩包,据说是linux下面的格式.但也是可以在windows上面安装的,安装过程,1,在 https://pypi.python.org/pypi 这个网 ...
- Codeforces 960D - Full Binary Tree Queries
960D - Full Binary Tree Queries 思路: 用move1[i]记录第i层第1种操作移动的个数(对这一层的个数取模) 用move2[i]记录第i层第2种操作移动的个数(对这一 ...