1 solutions

  • 0
    @ 1 year ago

    快速幂模板。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll a,b,m,ans=1;
    int main(){
    	scanf("%lld%lld%lld",&a,&b,&m);
    	while(b){
    		if(b%2) ans=ans*a%m;
    		a=a*a%m;
    		b/=2;
    	}
    	printf("%lld",ans); 
    }
    
    • 1

    Information

    ID
    196
    Time
    1000ms
    Memory
    512MiB
    Difficulty
    6
    Tags
    # Submissions
    17
    Accepted
    12
    Uploaded By