打板子機器啟動!

MX_muxi發表於2024-10-25
快讀
#include<bits/stdc++.h>
using namespace std;

const int N=1000005;

int n;
int ans;

int read(){
	int ff=1,kk=0;
	char cc=getchar();
	while(cc>'9'||cc<'0'){
		if(cc=='-')ff=-1;
		cc=getchar();
	}
	while(cc<='9'&&cc>='0'){
		kk=kk*10+cc-'0';
		cc=getchar();
	}
	return ff*kk;
}

int main(){
	n=read();
	
	printf("%d",ans);
	return 0;
}
快讀快輸
#include<bits/stdc++.h>
using namespace std;

const int N=1000005;

int n;
int ans;

int read(){
	int ff=1,kk=0;
	char cc=getchar();
	while(cc>'9'||cc<'0'){
		if(cc=='-')ff=-1;
		cc=getchar();
	}
	while(cc<='9'&&cc>='0'){
		kk=kk*10+cc-'0';
		cc=getchar();
	}
	return ff*kk;
}

void write(int x){
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+'0');
	return;
}

int main(){
	n=read();
	
	printf("%d",ans);
	//write(n);
	return 0;
}
P1226 【模板】快速冪
#include<bits/stdc++.h>
using namespace std;

int a,b,p;

int read(){
	int ff=1,kk=0;
	char cc=getchar();
	while(cc>'9'||cc<'0'){
		if(cc=='-')ff=-1;
		cc=getchar();
	}
	while(cc<='9'&&cc>='0'){
		kk=kk*10+cc-'0';
		cc=getchar();
	}
	return ff*kk;
}

int qpower(int x,int y){
	int ans=1;
	while(y){
		if(y&1)ans=1ll*ans*x%p;
		x=1ll*x*x%p;
		y>>=1;
	}
	return ans;
}

int main(){
	a=read();b=read();p=read();
	printf("%d^%d mod %d=%d",a,b,p,qpower(a,b));
	return 0;
}

相關文章