Cod sursa(job #2174761)
| Utilizator | Data | 16 martie 2018 13:20:41 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
#define lolo long long
#define mod 1999999973
using namespace std;
lolo lgput(lolo n, lolo po)
{
lolo rez = 1;
do
{
if(po & 1)
{
rez = (1LL * rez * n)%mod;
}
n = (n*n)%mod;
po = po >> 1;
}while(po);
return rez;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
lolo N, P;
fin >> N >> P;
fout << lgput(N,P);
return 0;
}
