Cod sursa(job #68939)

Utilizator M@2Te4iMatei Misarca M@2Te4i Data 30 iunie 2007 11:53:26
Problema Rsir Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include<stdio.h>

long long t[3],n;
int a,b,x,y,z,m;

void citire()
{
freopen("rsir.in","r",stdin);     
scanf("%lld%lld",&t[0], &t[1]);
scanf("%d%d%d%d%d%d",&a, &b, &x, &y, &z, &m);
scanf("%lld",&n);
fclose(stdin);
}     

void rezolvare()
{
for (int i=2; i<=n; i++)     
    {
    t[2]=a*t[0]*t[0];
    t[2]=t[2]+(b*t[1]*t[1]);
    t[2]=t[2]+(x*t[0]);
    t[2]=t[2]+(y*t[1]);
    t[2]=t[2]+z;
    t[2]=t[2]%m;
    t[0]=t[1];
    t[1]=t[2];
    }
}     

void scriere()
{
freopen("rsir.out","w",stdout);     
printf("%lld%",t[1]);
fclose(stdout);
}     

int main()
{
citire();    
rezolvare();
scriere();
return 0;    
}