Pagini recente » Cod sursa (job #1954374) | Cod sursa (job #1459396) | Cod sursa (job #937032) | Cod sursa (job #2616892) | Cod sursa (job #134931)
Cod sursa(job #134931)
#include<stdio.h>
long long int t0,t1,a,b,x,y,z,m,t2,n,i,p2,f0[7000],f1[7000],fr;
int main()
{
FILE *f,*g;f=fopen("rsir.in","r");g=fopen("rsir.out","w");
fscanf(f,"%lld%lld",&t0,&t1);
fscanf(f,"%lld%lld",&a,&b);
fscanf(f,"%lld%lld%lld",&x,&y,&z);
fscanf(f,"%lld",&m);
t0=t0%m;t1=t1%m;a=a%m;b=b%m;x=x%m;y=y%m;z=z%m;
for(i=0;i<m;i++){p2=(i*i)%m;f0[i]=(a*p2+x*i+z)%m;f1[i]=(b*p2+y*i)%m;}
for(;;)
{ t2=f0[t0]+f1[t1];if(t2>=m)t2-=m;t0=t1;t1=t2;
if(t2<16)fr++;
if(fr==112000)break;
}
fprintf(g,"%***\n",t0);
fcloseall();
return 0;
}