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]; for(int i=1;i<n;i++){ dp[i+1]+=min(dp[i-1]+x[i+1],dp[i]+x[i+1]); } cout<<dp[n]<<endl; return 0; }
Information
- ID
- 989
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- 6
- Tags
- # Submissions
- 18
- Accepted
- 12
- Uploaded By