Cod sursa(job #1264222)
Utilizator | Data | 15 noiembrie 2014 16:53:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include<fstream>
#include<cmath>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long c=1999999973;
long long t(long long a,long long b){
if(b==0) return 1;
else if(b==1) return a%c;
if(b%2==0) return (t(a,b/2)*t(a,b/2))%c;
if(b%2==1) return (t(a,b-1)*a)%c;
}
int main(){
long long n,p;
f>>n>>p;
g<<t(n,p);
return 0;
}