Mai intai trebuie sa te autentifici.
Cod sursa(job #627483)
| Utilizator | Data | 30 octombrie 2011 02:00:55 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include<fstream>
using namespace std;
long long rez, n, p;
long long Lgput(long long p){
if (p == 0) return 1;
if (p % 2 == 1) return Lgput (p-1) * n % 1999999973;
else {
long long x = Lgput (p/2) ;
return x * x % 1999999973;
}
}
int main(){
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
rez = Lgput(p);
fout<<rez<<"\n";
return 0;
}
