Cod sursa(job #2070597)
| Utilizator | Data | 19 noiembrie 2017 18:37:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long putere ( long long a, long long b, long long c ){
if ( b == 0){
return 1;
}
else{
long long r = putere(a, b/2,c);
r = r*r%c;
if( b%2 == 0)
return r;
else
return r*a%c;
}
}
long a, b;
int main(){
fin>>a>>b;
fout<<putere(a, b, 1999999973)<<" ";
}
