数论复习专题


一定要注意前提条件 !!!!gcd(a,p)=1

#include
using namespace std;
#define lowbit(x) x&(-x)
#define ll long long
mapmp;
ll mod,b,n; 
ll ksm(ll aa,ll bb){
	ll res=1;
	while(bb){
		if(bb&1)res=res*aa%mod;
		bb>>=1;aa=aa*aa%mod;
	}
	return res;
}
ll mul(ll aa,ll bb){
	ll res=0;
	while(bb){
		if(bb&1)res=(res+aa)%mod;
		bb>>=1;
		aa=aa*2%mod;
	}
	return res;
}
void bsgs(ll,ll);
int main(){
    cin>>mod>>b>>n;
    bsgs(b,n);
	return 0;
}
void bsgs(ll a,ll b){
	ll m=sqrt(mod)+1;
	ll now=b;
	for(int i=0;i