Cod sursa(job #3280363)
Utilizator | Data | 26 februarie 2025 11:49:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
#define int long long
#define mod 1999999973
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
int power (int A,int n) {
if (n==0) return 1;
if (n%2==1) return A%mod*power(A,n-1)%mod;
int P=power(A,n/2)%mod;
return P%mod*P%mod;
}
int32_t main() {
int n,p;
cin>>n>>p;
cout<<power(n,p);
}