Cod sursa(job #1648362)
| Utilizator | Data | 11 martie 2016 09:44:35 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a, b;
long long putere(long long a, long long b)
{
if (b == 0)
return 1;
if (b % 2 == 0)
return putere((a * a) % mod, b / 2) % mod;
return (a * (putere(a, b - 1) % mod)) % mod;
}
int main()
{
f >> a >> b;
g << putere(a, b) << '\n';
return 0;
}
