Cod sursa(job #2159258)
Utilizator | Andrei Usurelu programatorulupeste | Data | 10 martie 2018 20:39:17 |
---|---|---|---|
Problema | Rsir | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<fstream>
#include<cmath>
#define MAX 10000
using namespace std;
ifstream f("rsir.in");
ofstream g("rsir.out");
unsigned long t[MAX],A[MAX],B[MAX],n,M,a,b,x,y,z;
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();
ab();
for(unsigned long i=2;i<=n;i++)
solve(i);
g<<t[n];
return 0;
}