Pagini recente » Cod sursa (job #3135317) | Cod sursa (job #2745779) | Cod sursa (job #2186649) | Cod sursa (job #2042847) | Cod sursa (job #3135894)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define modulo 1999999973
void citire( const char* path, long long* x,long long *n)
{
FILE *f=fopen(path,"r");
fscanf(f,"%lld%lld",x,n);
fclose(f);
}
int expo(long long x, long long n)
{
if(n==0)
return 1;
if(n%2==1)
return (x*expo((x*x)%modulo,n/2))%modulo;
if(n%2==0)
return expo((x*x)%modulo,n/2)%modulo;
}
void scriere(const char* path,int p)
{
FILE *f=fopen(path,"w");
fprintf(f,"%d\n",p);
fclose(f);
}
int main(void)
{
long long x,n;
citire("lgput.in",&x,&n);
int power=expo(x,n);
scriere("lgput.out",power);
return 0;
}