Cod sursa(job #1377627)
Utilizator | Data | 5 martie 2015 23:11:38 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std;
const long long mod = 1999999973;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a, b;
fin >> a >> b;
long long p = 1;
while (b)
{
if (b % 2 == 1)
{
p *= a;
p %= mod;
}
a *= a;
a %= mod;
b /= 2;
}
fout << p << '\n';
return 0;
}