Cod sursa(job #2710141)
| Utilizator | Data | 21 februarie 2021 22:04:56 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream>
#include<iostream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n, p;
long long res = 1;
int main()
{
f >> n >> p;
while (p > 0)
{
if (p & 1)
res = (res * n) % 1999999973;
p = p >> 1;
n = (n * n) % 1999999973;
}
g << res;
}