Cod sursa(job #2101379)
Utilizator | Data | 7 ianuarie 2018 13:05:04 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p, r = 1;
int main()
{
fin >> n >> p;
while (p)
{
if (p^1)
{
r = (r*n) % MOD;
p--;
}
else
{
n = (n*n) % MOD;
p >>= 1;
}
}
fout << r;
return 0;
}