Cod sursa(job #2577884)
Utilizator | Data | 10 martie 2020 05:16:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
long long power(long long x,long long y)
{
int p=1;
while(y)
{
if(y%2)
{
p=p*y%1999999973;
y--;
}
x=x*x%1999999973;
y/=2;
}
return p;
}
long long n,p;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
g<<power(n,p);
g.close();
f.close();
return 0;
}