Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
30423 徐若宸 取余运算 C++ Accepted 0 MS 244 KB 290 2023-11-09 21:25:38

Tests(1/1):


#include <bits/stdc++.h> using namespace std; int b,p,k; int f(int p){ if(p==0)return 1; int tmp; tmp=f(p/2)%k; tmp=(tmp*tmp)%k; if(p%2==1){ tmp=(tmp*b)%k; } return tmp; } int main(){ cin>>b>>p>>k; int t=b; int ans=f(p); printf("%d^%d mod %d=%d",b,p,k,ans); }


Judgement Protocol: