Cod sursa(job #2282933)
Utilizator | Data | 14 noiembrie 2018 18:58:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
int rez=1,k=1999999973;
void log(int x,int y)
{
if(y)
{
if(y&1)
{
rez=((long long)rez*x)%k;
}
x=((long long)x*x)%k;
y/=2;
log(x,y);
}
}
int main()
{
int n,p;
f>>n>>p;
log(n,p);
g<<rez;
}