Pagini recente » Cod sursa (job #1594803) | Cod sursa (job #1518650) | Cod sursa (job #1430783) | Cod sursa (job #1943408) | Cod sursa (job #651293)
Cod sursa(job #651293)
#include "stdio.h"
unsigned int a,b,r;
FILE *f,*g;
void pow(unsigned int p,unsigned int x,unsigned int *rez)
{
if(p*2<=b)
{
pow(p*2,x*x,rez);
if(b>=p)
{
b-=p;
*rez*=x;
*rez %=1999999973;
}
}
else
{
*rez = x;
b-=p;
}
}
int main()
{
f = fopen("lgput.in","r");
g = fopen("lgput.out","w");
fscanf(f,"%d%d",&a,&b);
pow(1,a,&r);
fprintf(g,"%d",r%1999999973);
fclose(f);
fclose(g);
return 0;
}