Cod sursa(job #2001588)
| Utilizator | Data | 17 iulie 2017 09:27:47 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n, p, np = 1, i;
fin >> n >> p;
if(p%2==0)for(i=0; i<p/2; i++)np = (np * n * n) % 1999999973;
else
{
for(i=0; i<(p-1)/2; i++)np = (np * n * n) % 1999999973;
np = (np * n) % 1999999973;
}
fout << np;
return 0;
}
