Cod sursa(job #1259179)
Utilizator | Data | 9 noiembrie 2014 19:47:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include<iostream>
#include<fstream>
#define MOD 1999999973LL
using namespace std;
ifstream g("lgput.in");
ofstream f("lgput.out");
int power(int b, int e)
{
if(e == 0)
return 1;
if(e % 2 == 0)
return (power(b, e/2) * power(b, e/2)) % MOD;
return (b * power(b, e - 1)) % MOD;
}
int main()
{
int b, e;
g >> b >> e;
f << power(b, e);
}