Cod sursa(job #2569138)
| Utilizator | Data | 4 martie 2020 11:15:23 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
//ALEXANDRU MICLEA
#include <bits/stdc++.h>
using namespace std;
#include <fstream>
ifstream fin("lgput.in"); ofstream fout("lgput.out");
//VARIABLES
long long n, p;
const long long MOD = 1999999973;
//FUNCTIONS
long long lgput(){
long long ans = 1;
while (p){
if (p % 2 == 1){
ans *= n;
ans %= MOD;
}
n *= n;
n %= MOD;
p /= 2;
}
return ans;
}
//MAIN
int main() {
fin >> n >> p;
fout << lgput();
}
