Index calculation
July 1st is the founding day of the party. From 1921 to 2020, the Communist Party of China has led the Chinese people through 99 years.
Please calculate: 7 ^ 2020 mod 1921, where A mod B represents the remainder of A divided by B.
#include <iostream>
using namespace std;
//递归求解
int power(int b, int p, int s){
if(p != 0)
return (b*power(b,p-1,s)%s);
else
return 1;
}
int main(){
int b,p,s,res; //b为基数,P为指数,s为取余
cin >> b >> p >>s;
res = power(b,p,s);
cout << res;
return 0;
}