Cod sursa(job #2627923)
| Utilizator | Data | 13 iunie 2020 13:52:10 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int mod = 1999999973;
long long ridicareLaPutere(int n, int p){
long long r = 1;
while(p > 0) {
if(p % 2 == 1)
r = r * n;
p /= 2;
r *= n;
}
return r % mod;
}
int main(){
ifstream fin("lgput.in");
ofstream fout("lgput.out")
int n, p;
fin >> n >> p;
fout << ridicareLaPutere(n, p);
return 0;
}
