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