14 条题解

  • 1
    @ 2025-3-5 17:31:30

    快速幂模版

    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+5,INF=0x3f3f3f3f;
    typedef long long LL;
    LL a,b,p; 
    LL power(){
    	LL ans=1;
    	while(b){
    		if(b&1)ans = ans*a%p;
    		b>>=1;
    		a = a*a%p;
    	}
    	return ans%p;
    }
    int main()
    {
    	cin>>a>>b>>p;
    	cout<<power();
    	return 0;
    }
    
    

信息

ID
2
时间
1000ms
内存
128MiB
难度
8
标签
递交数
3398
已通过
515
上传者