Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- ll S(int a1, int d, int n){
- return (2*a1 + d * (n - 1)) * n / 2;
- }
- bool sh=0;
- ll N,A,B,C,ans, ans_bef;
- ll f(int i, int k){
- return S(A, A, N - 1 - i) + C * (i + 1) + S(B, B, i - k - 1) + S(A, A, k + 1);
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin>>N>>A>>B>>C;
- ans=C*N + S(A,A,N) + S(B,B,N);
- for (int i=0;i<N;++i){
- for (int k = 0; k < i; ++k){
- ans = min(ans, f(i,k));
- }
- }
- cout<<ans;
- }
- /*
- 6
- 20
- 10
- 5
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement