Cod sursa(job #1368219)
Utilizator | Data | 2 martie 2015 15:15:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long expo(long a, long b)
{
long x = 1;
while(b)
{
if(b & 1 == 1)
x = (x * a) % 1999999973;
b >>= 1;
a *= a;
}
return x % 1999999973;
}
int main()
{
int a, b;
f >> a >> b;
g << expo(a, b);
}