Cod sursa(job #1608756)
| Utilizator | Data | 22 februarie 2016 12:37:12 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#define modulo 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long pow(int a, int b)
{
if (b == 0)
return (1);
if (b == 1)
return (a);
if (b % 2 == 1)
return (a * pow(a * a, b - 1));
else
return (pow(a * a, b / 2));
}
int main()
{
int a, b;
f >> a >> b;
g << pow(a, b) % modulo;
return 0;
}
