Time limit : 2sec / Memory limit : 256MB

Score :  points

Problem Statement

There is a hotel with the following accommodation fee:

  •  yen (the currency of Japan) per night, for the first  nights
  •  yen per night, for the -th and subsequent nights

Tak is staying at this hotel for  consecutive nights. Find his total accommodation fee.

Constraints

  •  are integers.

Input

The input is given from Standard Input in the following format:




Output

Print Tak's total accommodation fee.


Sample Input 1

Copy
5
3
10000
9000

Sample Output 1

Copy
48000

The accommodation fee is as follows:

  •  yen for the -st night
  •  yen for the -nd night
  •  yen for the -rd night
  •  yen for the -th night
  •  yen for the -th night

Thus, the total is  yen.


Sample Input 2

Copy
2
3
10000
9000

Sample Output 2

Copy
20000

题解:水过
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
return x>y;
}
const int N=;
const int mod=1e9+;
int main()
{
std::ios::sync_with_stdio(false);
int n,k,x,y;
cin>>n>>k>>x>>y;
ll s=;
if(n<=k) s+=n*x;
else s+=k*x+(n-k)*y;
cout<<s<<endl;
return ;
}
04-30 06:01