Cod sursa(job #2312321)
Utilizator | Data | 4 ianuarie 2019 17:49:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
const int n_max = 10001;
int main()
{
unsigned long long sol=1, n, p;
unsigned int i;
ifstream f("lgput.in");
ofstream g("lgput.out");
f >> n >> p;
for (i=0;(unsigned long long)(1<<i) <= p;i++)
{
if ((1<<i) & p)
sol = sol*n % 1999999973;
n=n*n % 1999999973;
}
g << sol;
return 0;
}