Cod sursa(job #1880144)
Utilizator | Data | 15 februarie 2017 16:05:46 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int pow(int x, int put){
if(put==1)
return x%1999999973;
if(put%2==0)
return pow(x*x,put/2)%1999999973;
else return x*pow(x*x,put/2)%1999999973;
}
int main(){
int n,p;
in>>n>>p;
out<<pow(n,p);
return 0;
}