Cod sursa(job #632792)
Utilizator | Data | 12 noiembrie 2011 12:46:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long func(int a , int b){
if(b==0)
return 1;
else {
long long aux= func ( a ,b/2);
if(b%2==0)
return (aux*aux)%1999999973;
else return ((aux*aux)%1999999973)*a%1999999973;
}
}
int main(){
int n , p;
f>>n>>p;
g<<func(n,p);
return 0;
}