//大数幂取模 #include "iostream" using namespace std; //(a^b) % m int mod(int a,int b,int m){ int result = 1; for(int i=0;i<b;i++) { result = (result*a) %m; } return result; } int main(){ cout << mod(2,4,5) << endl; }
时间: 2024-11-01 03:53:49
//大数幂取模 #include "iostream" using namespace std; //(a^b) % m int mod(int a,int b,int m){ int result = 1; for(int i=0;i<b;i++) { result = (result*a) %m; } return result; } int main(){ cout << mod(2,4,5) << endl; }