Pagini recente » Cod sursa (job #577517) | Cod sursa (job #2037753) | Cod sursa (job #1251381) | Cod sursa (job #2702879) | Cod sursa (job #1656806)
#include <iostream>
#include <stdio.h>
using namespace std;
long long int N,P;
long long int lg(long long int N , long long int P){
if(P==0) return 1;
if(P==1) return N;
if(P%2==0) return lg(N*N,P/2);
else return N*lg(N*N,(P-1)/2);
}
int main()
{
FILE *f1,*f2;
f1=fopen("lgput.in","r");
f2=fopen("lgput.out","w");
fscanf(f1,"%lld",&N);
fscanf(f1,"%lld",&P);
fprintf(f2,"%lld",lg(N,P));
fclose(f1);
fclose(f2);
}