Cod sursa(job #2159635)
Utilizator | Data | 11 martie 2018 07:12:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include<iostream>
#include<fstream>
#define ull unsigned long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ull a,b;
const ull MOD = 1999999973;
ull powr(ull x,ull y)
{
ull p=1;
while(y)
{
while(y%2==0)
{
y/=2;
x*=x;
}
p*=x;
p=p%MOD;
y--;
}
return p;
}
int main()
{
f>>a>>b;
g<<powr(a,b)%MOD;
return 0;
}