Cod sursa(job #2756655)
Utilizator | Data | 2 iunie 2021 11:39:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
using namespace std;
const int Mod = 1999999973;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p, a = 1;
fin >> n >> p;
while (p != 0)
{
if (p % 2 == 1)
{
a *= n;
}
n *= n;
p /= 2;
n %= Mod;
a %= Mod;
}
fout << a % Mod;
return 0;
}