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