⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 大指数幂模运算.cpp

📁 本程序的功能是实现大指数幂的模运算
💻 CPP
字号:
#include <iostream>
using namespace std;

#define PUBLICKEY 187

long module(long key,long exponential)	//key:底数	exponential:指数	mod:模
{
	if (exponential==0)		return 1;
	long mod=module(key,exponential/2);
	if (exponential%2==0)	return mod*mod%PUBLICKEY;
	else return (mod*mod)%PUBLICKEY*key%PUBLICKEY; 
}

main()
{
	long key,exponential;
	cout<<"			大指数幂模运算"<<endl;
	cout<<"请输入底数:";
	cin>>key;
	cout<<"请输入指数:";
	cin>>exponential;
	cout<<"模为: "<<module(key,exponential)<<endl;
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -