Cod sursa(job #1524948)
| Utilizator | Data | 14 noiembrie 2015 16:25:05 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
using namespace std;
int p = 1999999973;
int power(long long a, int b)
{
if(b == 1)
return a;
if(b%2==1)
{
long long temp = a*power(a,b-1);
return temp%p;
}
else{
long long ab2 = power(a, b/2);
ab2 = ab2*ab2;
return ab2%p;
}
}
int main()
{
ofstream out("lgput.out");
ifstream in("lgput.in");
int a, b;
in >> a >> b;
out << power(a,b);
return 0;
}
