Cod sursa(job #2305132)
Utilizator | Data | 19 decembrie 2018 13:09:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
// #define fin cin
// #define fout cout
int modulo=1999999973;
int LG(int y);
int x, y;
int main()
{
fin>>x>>y;
fout<<LG(y)<<'\n';
return 0;
}
int LG(int y)
{
if(y==1) return x% modulo;
int temp=LG(y/2);
if(y%2) return (((1LL * temp*temp) % modulo )*x)%modulo;
return (1LL * temp*temp)%modulo;
}