Cod sursa(job #2159253)
| Utilizator | Data | 10 martie 2018 20:37:30 | |
|---|---|---|---|
| Problema | Rsir | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 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(int i=2;i<=n;i++)
solve(i);
g<<t[n];
return 0;
}