Pagini recente » Cod sursa (job #2077581) | Cod sursa (job #2719600) | Cod sursa (job #2517692) | Cod sursa (job #353482) | Cod sursa (job #3136536)
#include <stdio.h>
#include <stdlib.h>
long long int exponent_log(long long int x, long long int n)
{
if(n == 0)
{
return 1;
}
if(n % 2 == 0)
{
return exponent_log((x*x)%1999999973, n/2);
}
else //if(n % 2 == 1)
{
return (x * exponent_log((x*x)%1999999973, n/2))%1999999973;
}
}
int main ()
{
long long int n = 0;
long long int p = 0;
long long int exponentiala = 0;
FILE *file_in = NULL;
FILE * file_out = NULL;
if((file_in = fopen("lgput.in","r")) == NULL)
{
perror("EROARE LA DESCHIDEREA FISIERULUI DE CITIRE !");
exit(-1);
}
if((file_out = fopen("lgput.out","w")) == NULL)
{
perror("EROARE LA DESCHIDEREA FISIERULUI DE SCRIERE !");
exit(-1);
}
fscanf(file_in,"%lld",&n);
fscanf(file_in,"%lld",&p);
exponentiala = exponent_log(n,p);
fprintf(file_out,"%lld",exponentiala);
fclose(file_in);
fclose(file_out);
return 0;
}