Cod sursa(job #2434471)
Utilizator | Hurjui Alexandru-Mihai hurjui12Alexandru | Data | 2 iulie 2019 01:15:00 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
//
// main.cpp
// Alex
//
// Created by Hurjui Alexandru Mihai on 02/11/2018.
// Copyright © 2019 Hurjui Alexandru Mihai. All rights reserved.
//
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long a, b, p = 1;
const long long r = 1999999973;
fin >> a >> b;
while (b > 0)
{
if (b% 2== 1)
{
p = p * a;
p = p % r;
}
a = a*a % r;
b= b/2;
}
fout << p;
return 0;
}