Cod sursa(job #2167974)
Utilizator | Data | 14 martie 2018 08:42:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <math.h>
#define MOD 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
unsigned int n,p;
unsigned long long putere(int x,int y)
{
unsigned long long r=1;
while(y)
{
if(y%2==1)
r=(r*x)%MOD;
x=(x*x)%MOD;
y/=2;
}
return r;
}
int main()
{
in>>n>>p;
out<<putere(n,p);
return 0;
}