Cod sursa(job #1810603)
Utilizator | Data | 20 noiembrie 2016 12:29:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
#define tip long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int MOD=1999999973;
tip p,n,putere(tip,tip);
int main()
{
f>>n>>p;
g<<putere(n,p);
return 0;
}
tip putere(tip b,tip e)
{
tip r=1;
while(e)
{
if(e%2)
r=(r*b)%MOD;
b=(b*b)%MOD;
e/=2;
}
return r;
}