Pagini recente » Cod sursa (job #2986482) | Cod sursa (job #386823) | Cod sursa (job #122359) | Cod sursa (job #2816450) | Cod sursa (job #2168180)
#include<fstream>
#include<cmath>
#define MAX 10000
using namespace std;
ifstream f("rsir.in");
ofstream g("rsir.out");
unsigned short M,a,b,x,y,z;
unsigned long long n,t[MAX],A[MAX],B[MAX];
void citire(){
f>>t[0]>>t[1]>>a>>b>>x>>y>>z>>M>>n;
}
void ab(){
for(int i=1;i<=7000;i++){A[i]=a*i*i+x*i+z;
B[i]=b*i*i+y*i;
}
}
void solve(int i){
t[i]=(A[t[i-1]]+B[t[i-2]])%M;
}
int main() {
citire();
if(a<=1000&&b<=1000&&x<=1000&&y<=1000&&z<=1000&&M<=7000&&n<=pow(10,16)&&t[0]<=pow(10,9)&&t[1]<=pow(10,9)){
ab();
for(unsigned long i=2;i<=n;i++)
solve(i);
g<<t[n];}
return 0;
}