Cod sursa(job #2500501)
Utilizator | Data | 28 noiembrie 2019 08:51:27 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
const long long MOD=1999999973;
long long N,exp, x, y;
int main()
{
cin>>N>>exp;
x=N%MOD;y=1;
while(exp)
{
if(exp%2==0){
x=(x*x)%MOD;
exp=exp/2;
}
else{
y=(y*x)%MOD;
x=(x*x)%MOD;
exp=exp/2;
}
}
cout<<y<<'\n';
return 0;
}
///nerecursiv