Cod sursa(job #1535455)
Utilizator | Vlad Stoleru vlad00 | Data | 24 noiembrie 2015 19:38:54 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
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, g<<putere(a,b);
return 0;
}