Cod sursa(job #2278221)
Utilizator | Data | 7 noiembrie 2018 14:51:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long int exp(int x,int y)
{
if(y==0)
{
return 1;
}
if(y%2)
{
return x*exp(x,y-1);
}
if(!(y%2))
{
return exp(x,y/2)*exp(x,y/2);
}
}
int main()
{
long int n,p;
f>>n>>p;
g<<(long)((exp(n,p))%1999999973);
}