栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

指数循环节

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

指数循环节

指数循环节 定义

若干证明

引入


当n很大时,我们需要降幂进行处理
此时,用到一个新的东西,指数循环节

练习题:

Poj2837

套用上面公式(特别是快速幂的部分)即可

此题涉及到快速幂+欧拉函数(可见之前博客)欧拉函数

**注:**只有在B大于等于C的欧拉函数值时,才可以套用此公式。

Calculation(指数循环节,欧拉函数的常用公式)

Code:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define pi 3.14159265358979
#define SIS std::ios::sync_with_stdio(false)
//#define printf __mingw_printf
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pairPLL;
typedef pairPII;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn = 1e6+5;

char str[maxn];

ll gcd(ll a,ll b) {
	if(b==0)
		return a;
	return gcd(b,a%b);
}

ll pow_mod(ll a,ll x,ll mod) {
	if(a==0)
		return x==0;
	ll ans=1;
	while(x) {
		if(x&1)
			ans=ans*a%mod;
		x>>=1;
		a=a*a%mod;
	}
	if(ans==0)
		return mod;
	return ans%mod;
}

ll phi(ll x) {
	ll ans=x;
	for(int i=2; i*i<=x; i++) {
		if(x%i==0)
			ans=ans*(i-1)/i;
		while(x%i==0)
			x/=i;
	}
	if(x>1)
		ans=ans*(x-1)/x;
	return ans;
}

ll f(ll x,ll mod){
	if(x<10)
		return x;
	return pow_mod(x%10,f(x/10,phi(mod)),mod);
}

void solve(ll a,char str[],ll c){
	ll len=strlen(str);
	ll ans=0;
	ll p=phi(c);
	if(len<=15){
		for(int i=0;i>a>>str>>c){
		solve(a,str,c);
	}
	return 0;
}
其他题目(自学尚未完成)

指数循环节(指数降幂)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/303993.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号