Cod sursa(job #1609713)
Utilizator | Data | 22 februarie 2016 22:55:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
const long long MOD = 1999999973;
int main()
{
ifstream in("lgput.in");
ofstream out("lgput.out");
int n, p;
in >> n >> p;
long long x = n;
long long sol = 1;
while (p)
{
if (p % 2 == 1)
sol = (sol * x) % MOD;
x = (x * x) % MOD;
p /= 2;
}
out << sol << '\n';
return 0;
}