Cod sursa(job #2562325)
Utilizator | Data | 29 februarie 2020 13:29:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int P(unsigned int a, unsigned int n)
{
unsigned int p = 1;
while (n > 0)
{
if (n % 2 == 1)
p = 1LL * p * a % 1999999973;
a = 1LL * a * a % 1999999973;
n /= 2;
}
return p;
}
int main()
{
unsigned int a, b;
fin >> a >> b;
fout << P(a, b);
return 0;
}