Cod sursa(job #2384633)
| Utilizator | Data | 20 martie 2019 22:54:04 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long N,M,ans;
long LG(int ex)
{
if(ex==1) return (N%MOD);
if(ex%2==0)
{
long hup=LG(ex/2);
return (hup*hup)%MOD;
}
else
{
long hup=LG((ex-1)/2);
return (N*hup*hup)%MOD;
}
}
int main()
{
f>>N>>M;
g<<LG(M)%MOD;
return 0;
}
