Cod sursa(job #1535454)
| Utilizator | Data | 24 noiembrie 2015 19:38:31 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long putere(long long base,long long exponent){
if(exponent==0)
return 1;
if(exponent%2)
return base*putere(base*base,exponent/2)%mod;
return putere(base*base,exponent/2)%mod;
}
int main()
{
long long a,b;
f>>a>>b, c<<putere(a,b);
return 0;
}
