Pagini recente » Cod sursa (job #2047056) | Cod sursa (job #1990150) | Cod sursa (job #767537) | Cod sursa (job #2867129) | Cod sursa (job #751144)
Cod sursa(job #751144)
#include<fstream>
using namespace std;
int main(){
int n,p,w,y,cp;
long long x,k;
ifstream in("lgput.in");
ofstream out("lgput.out");
in>>n>>p;
x=n;
k=1;
w=1999999973;
y=1;
cp=p;
while(p>0){
while(p%2==0){
x=(long long)(x*x)%w;
p=p/2;
y=y*2;
}
p=p-1;
if(p==0){
p=cp-y;
cp=p;
y=1;
k=(long long)(k*x)%w;
x=n;
}
}
out<<k;
return 0;
}