1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=1e5; int main() { int n,A,B,C,x[N],dp[N]; cin>>n>>A>>B>>C; for (int i = 1; i <= n; i++){ int tmp = ((long long)A * i * i + B * i + C) % 20000; x[i] = tmp - 10000; } dp[1]=x[1],dp[2]=x[2]; for(int i=3;i<=n;i++){ dp[i]+=max(dp[i-1],dp[i-2])+x[i]; } cout<<dp[n-1]; return 0; }
Information
- ID
- 988
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- 6
- Tags
- # Submissions
- 52
- Accepted
- 15
- Uploaded By