Cod sursa(job #2636261)
Utilizator | Data | 17 iulie 2020 13:39:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int mod = 1999999973;
int main()
{
int n, p;
f >> n >> p;
int x = 1, v = n;
int i = 1;
while (i <= p)
{
if ((i & p) != 0)
{
//cout << i << '\n';
x = (1LL * x * v) % mod;
}
v = (1LL * v * v) % mod;
i <<= 1;
}
g << x;
return 0;
}