Cod sursa(job #1157111)
| Utilizator | Data | 28 martie 2014 11:36:24 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a, b, m;
long long putere(long long a, long long b){
long long rez;
if (b == 1)
return a % 1999999973;
if (b == 2)
return a * a % 1999999973;
if (b % 2 == 1)
return a * putere(a, b - 1) % 1999999973;
else {
rez = putere(a, b / 2) % 1999999973;
return rez * rez % 1999999973;
}
}
int main(){
fin >> a >> b;
fout << putere(a, b);
}
