Cod sursa(job #2639015)
Utilizator | Data | 30 iulie 2020 20:53:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
const int MOD = 1999999973;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
long long int n,p;
long long int rez=1;
f>>n>>p;
long long int x=n;
while(p>0)
{
if(p%2==1)
{
rez=rez*x;
}
x=x*x;
p=p/2;
}
g<<rez;
return 0;
}