Cod sursa(job #2484147)
Utilizator | Data | 30 octombrie 2019 18:32:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
#define ull unsigned long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ull putlog(ull x, ull n){
ull P = 1;
while(n){
if(n%2 == 1){
P = (P*x)%MOD;
}
x = (x*x)%MOD;
n = n/2;
}
return P;
}
int main()
{
ull x,n;
fin>>x>>n;
fout<<(putlog(x,n)%MOD)<<'\n';
return 0;
}