Cod sursa(job #1919577)
Utilizator | Data | 9 martie 2017 20:07:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p;
long long Putere()
{
long long x=1;
while(p)
{
if(p%2)
{
x=(x*n)%MOD;
p--;
}
n=(n*n)%MOD;
p=p/2;
}
return x;
}
int main()
{
f >> n >> p;
g << Putere();
return 0;
}