Cod sursa(job #2175633)
Utilizator | Data | 16 martie 2018 18:11:18 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,m;
int log_exp(int x,int y)
{
if(y == 0) return 1;
int temp = log_exp(x,y/2);
if(y%2 == 0) return temp*temp;
else return x*temp*temp;
}
int main()
{
fin>>n>>m;
fout<<log_exp(n,m)%1999999973;
}