Cod sursa(job #2344987)
| Utilizator | Data | 15 februarie 2019 19:41:44 | |
|---|---|---|---|
| Problema | Divk | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <bits/stdc++.h>
using namespace std;
const int d = 1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned long long N, P;
int power(unsigned long long x, unsigned long long n){
if(n == 0){
return 1;
} else {
if(n == 1)
return x % d;
else {
if(n % 2 == 0) {
return power(x * x, n / 2) % d;
} else if(n % 2 == 1) {
return (x * power(x * x, (n - 1) / 2)) % d;
}
}
}
}
int main(){
fin >> N >> P;
fout << power(N, P);
return 0;
}
