欧拉降幂 (a^t)%c 模板
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,c,p,mod;
char t[];
ll phi(ll n)
{
ll res=n;
for(int i=;i*i<=n;i++){
if(n%i==){
res=res/i*(i-);
while(n%i==)
n/=i;
}
}
if(n>)
res=res/n*(n-);
return res;
}
ll quickpower(ll a,ll b,ll c)
{
ll ans=;
while(b)
{
if(b&)
ans=(ans*a)%c;
a=(a*a)%c;
b>>=;
}
return ans;
}
int main()
{
while(~scanf("%lld%s%lld",&a,t,&c)){
int len=strlen(t);
ll p=phi(c);
ll ans=;
for(ll i=;i<len;i++)
ans=(ans*+t[i]-'')%p;
ans+=p;
printf("%lld\n",quickpower(a,ans,c));
}
}
欧拉降幂 (a^t)%c 模板的更多相关文章
- 牛客OI测试赛 F 子序列 组合数学 欧拉降幂公式模板
链接:https://www.nowcoder.com/acm/contest/181/F来源:牛客网 题目描述 给出一个长度为n的序列,你需要计算出所有长度为k的子序列中,除最大最小数之外所有数的乘 ...
- FZU 1759 题解 欧拉降幂
本题考点:欧拉降幂 Super A^B mod C Given A,B,C, You should quickly calculate the result of A^B mod C. (1<= ...
- 数学--数论--欧拉降幂--P5091 欧拉定理
题目背景 出题人也想写有趣的题面,可惜并没有能力. 题目描述 给你三个正整数,a,m,ba,m,ba,m,b,你需要求:ab mod ma^b \bmod mabmodm 输入格式 一行三个整数,a, ...
- hdu4549 矩阵快速幂 + 欧拉降幂
R - M斐波那契数列 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- bzoj3884: 上帝与集合的正确用法 欧拉降幂公式
欧拉降幂公式:http://blog.csdn.net/acdreamers/article/details/8236942 糖教题解处:http://blog.csdn.net/skywalkert ...
- 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} ...
- D - Power Tower欧拉降幂公式
题意:给你一个数组a,q次查询,每次l,r,要求 \(a_{l}^{a_{l+1}}^{a_{l+2}}...{a_r}\) 题解:由欧拉降幂可知,最多log次eu(m)肯定变1,那么直接暴力即可,还 ...
- Applese涂颜色-欧拉降幂公式
链接:https://ac.nowcoder.com/acm/contest/330/E来源:牛客网 题目描述 精通程序设计的 Applese 叕写了一个游戏. 在这个游戏中,有一个 n 行 m 列的 ...
- TOJ 3151: H1N1's Problem(欧拉降幂)
传送门:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3151 时间限制(普通/Java): ...
- HDU4704(SummerTrainingDay04-A 欧拉降幂公式)
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submi ...
随机推荐
- hdu1005 矩阵快速幂
#include<iostream> #include<cstdio> #include<cstring> #include<set> #include ...
- 假期学习【十一】Python爬取百度词条写入csv格式 python 2020.2.10
今天主要完成了根据爬取的txt文档,从百度分类从信息科学类爬取百度词条信息,并写入CSV格式文件. txt格式文件如图: 为自己爬取内容分词后的结果. 代码如下: import requests fr ...
- pytest-fixture之conftest.py
场景: 对于一个py文件中某些用例需要前置条件,某些用例不需要前置条件的情况,使用setup/teardown肯定是不方便的, 这时就需要自定义测试用例的前置条件. 1.fixture优点: 命名不局 ...
- pom中<scope></scope>一些理解
compile:默认值,表示当前依赖包,要参与当前项目的编译,后续测试,运行时,打包provided:代表在编译和测试的时候用,运行,打包的时候不会打包进去test:表示当前依赖包只参与测试时的工作: ...
- linux - mysql 异常:ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
问题描述 ERROR 1820 (HY000): You must SET PASSWORD before executing this statement 备注:新安装完数据库后,在 xshell ...
- JS高级---沙箱小案例
沙箱小案例 substr截取, 从指定的字段开始截取 (function () { var str="小白喜欢小黑"; str=str.substr(2); console.log ...
- rest_framework:解析器
一.解析器的作用 根据请求头content-type选择对应的解析器对请求体内容进行处理. 有application/json,x-www-form-urlencoded,form-data等格式 二 ...
- PHP csv文件30w+数据导入mysql数据库
<?php class Add { public function data() { ini_set('memory_limit', '-1'); //PHP内存设置 $handle=fopen ...
- mysql-sql分析策略及优化
tranlation事务:从失败中回复到正常状态的方法多个应用并发访问数据库时,提供隔离方法 acid原子性:要么成功.要么失败一致性:数据保持“合理性”隔离型:多个事务同时并发执行,每个事务就像各自 ...
- 洛谷P2158 [SDOI2008]仪仗队 欧拉函数的应用
https://www.luogu.org/problem/P2158 #include<bits/stdc++.h> #define int long long using namesp ...