Go: package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)
func main2(){
ans(10,3,50,4,60)
ans(10 ,3, 100, 5, 180)//360
ans(6, 2, 200, 3, 300)// 600

}

func main() {



    sc := bufio.NewScanner(os.Stdin)
     sc.Scan()
        args := strings.Split(sc.Text(), " ")
      

	var n, a, b, c, d int

	n, _ = strconv.Atoi(args[0])
	a, _ = strconv.Atoi(args[1])
	b, _ = strconv.Atoi(args[2])
	c, _ = strconv.Atoi(args[3])
	d, _ = strconv.Atoi(args[4])

        ans(n,a,b,c,d)
}

func ans(n,a,b,c,d int){

	ans2 := 0
	for i := 0; i < 1000; i++ {
		if i*a >= n {
			ans2 = i * b
			break
		}
	}

	for i := 0; i < 1000; i++ {
	
		if i*c >= n {
			if ans2 > i*d {


				ans2 = i *  d
			}
			break
		}
	}

	fmt.Printf("%d\n", ans2)
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;

  if(n%a==0) cout << b*(n/a);
  else if(n%c==0) cout << d*(n/c);

  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int n,a,b,c,d; 
    cin >> n >> a >> b >> c >> d;
    int numa,numc;
    if(n%a==0){
        numa = n/a;
    }else{
        numa = n/a+1;
    }
    if(n%c==0){
        numc = n/c;
    }else{
        numc = n/c+1;
    }
    cout << min(numa*b,numc*d) << endl;
}

C++: #include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>


using namespace::std;

int main (){
//def
	float n,a,c;
	int b,d,cost;
//in
	cin>>n>>a>>b>>c>>d;
//main
	cost = min(b*(ceil(n/a)),d*(ceil(n/c)));
	cout<<cost<<endl;
	return 0;
}

C++: #include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d,n,y,x;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	if(n%a!=0)	x+=1;
	x*=b;
	y=n/c;
	if(n%c!=0)	y+=1;
	y*=d;
	if(x<y)	printf("%d\n",x);
	else	printf("%d\n",y);
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll x = (n + a - 1) / a * b;
    ll y = (n + c - 1) / c * d;
    cout << min(x, y) << endl;
    return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
	int n, a, b, c, d;
	int sum_a = 0; int sum_b = 0;
	int sum_c = 0; int sum_d = 0;
	cin >> n >> a >> b >> c >> d;
	while (sum_a < n) { sum_a += a; sum_b += b; }
	while (sum_c < n) { sum_c += c; sum_d += d; }
	if (sum_b < sum_d) cout << sum_b << endl;
	else cout << sum_d << endl;
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;

int main (){
    int n,a,b,c,d;
    int cost_a, cost_c;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);

    if(n%a == 0){
        cost_a = n/a * b;
    }else{
        cost_a = (n/a+1) * b;
    }

    if(n%c == 0){
        cost_c = n/c * d;
    } else {
        cost_c = (n/c+1) * d;
    }

    printf("%d\n", min(cost_a,cost_c));
    return 0;
}

C++: // Pencils 2018/12/27

#include <cstdio>

int main() {
    int N, A, B, C, D;
    int x, y;

    scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);

    x = (N / A + N % A) * B; // 円
    y = (N / C + N % C) * D; // 円

    if (x <= y) printf("%d\n", x);
    else printf("%d\n", y);

    return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main(void){
  int N,A,B,C,D,s,t;
    scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
    double x=ceil(N/A);
    double y=ceil(N/C);
    if (B*x <= D*y)
      {printf("%f\n",B*x);}
    else{printf("%f\n",D*y);}

return 0;
}

C++: #include<string.h>
int main(void)
{	
	int n,x,y,a,b,c,d;
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=n/a*b;
	y=n/c*d;
	if(n%a>0){
		x=x+b;
	}
	if(n%c>0){
		y=y+d;
	}
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	cout<<min(((n+a-1)/a)*b,((n+c-1)/c)*d)<<endl;
}

C++: #include <iostream>
#include<algorithm>
using namespace std;

int main()
{
    int n,a,b,c,d;
    cin >> n>>a>> b>>c>>d;
    int xn=(n%a==0?n/a:n/a+1);
    int yn=(n%c==0?n/c:n/c+1);
    cout << min(b*xn,d*yn)<< endl;
    return 0;

}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641


#include<iostream>
 using namespace std; //標準名前空間を使用

int main(){

    /変数を読み込む
    int N , A , B ,C ,D ;
    int Xset , Yset , Xprice , Yprice;

    // セットXで揃えた場合のの必要セット数(Xset)を求める
    Xset = N / A + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Xprice = Xset * B ;


    // セットYで揃えた場合のの必要セット数(Yset)を求める
    Yset = N / C + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Yprice = Yset * D ;

    //XpriceとYpriceを比較する
    if(Xprice < Yprice){
    cout << Xprice ; //XpriceがYpriceより小さい場合、Xpriceを出力
    }else{
    out << Yprice ; //そうでない場合、Ypriceを出力
    }

 return 0;

 }

C++: //https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0641?year=2018

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    int x = ((n + a - 1) / a) * b;
    int y = ((n + c - 1) / c) * d;
    cout << min(x, y) << endl;
    return 0;
}

/*
 *
 */

C++: #include<iostream>

using namespace std;
int main()
{
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	int moneyX=0,moneyY=0;
	for(int i=0;i<n;){
		moneyX+=b;
		i+=a;
	}
	//cout<<moneyX<<endl; 	
	for(int i=0;i<n;){
		moneyY+=d;
		i+=c;
		
	}	
	//cout<<moneyY<<endl;
	if (moneyX<=moneyY){
		cout<<moneyX<<endl; 
	}
	else cout<<moneyY<<endl;

}

C++: #include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	int Xcount = (N%A > 0) ? N / A + 1 : N / A;
	int Ycount = (N%C > 0) ? N / C + 1 : N / C;

	int Xprice = B * Xcount;
	int Yprice = D * Ycount;

	int minPrice = min(Xprice, Yprice);

	cout << minPrice << endl;

	return 0;
}