Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()
	d, _ := nextInt()

	costX := b * int(math.Ceil(float64(n)/float64(a)))
	costY := d * int(math.Ceil(float64(n)/float64(c)))
	fmt.Println(min(costX, costY))
}

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)を求める
    if( N % A == 0){
        Xset = N / A ;
    }else{
        Xset = N / A + 1 ;
    }

    // セットXで揃えた場合の合計金額を求める
    Xprice = Xset * B ;


    // セットYで揃えた場合のの必要セット数(Yset)を求める

    if( N % C == 0){
        Yset = N / C ;
    }else{
        Yset = N / C + 1 ;
    }

    // セットXで揃えた場合の合計金額を求める
    Yprice = Yset * D ;

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

 return 0;

 }

 // 注：割り算の繰上げはceilでもできる

C++: #include <iostream>
 
using namespace std;
 
int N,A,B,C,D;
int X_SET,Y_SET,X_SUM,Y_SUM;
int main(){
cin>>N>>A>>B>>C>>D;
X_SET = N/A;
if(N%A>0)X_SET=X_SET+1;
Y_SET=N/C;
if(N%C>0)Y_SET=Y_SET+1;
X_SUM=B*X_SET;
Y_SUM=D*Y_SET;
if(X_SUM<Y_SUM)cout<<X_SUM<<endl;
else
cout<<Y_SUM<<endl;
return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define RS resize

int main()
{
	int a, A, b, B, N;
	cin >> N >> a >> A >> b >> B;
	int x, y;
	x = ((a + N - 1) / a) * A;
	y = ((b + N - 1) / b) * B;
	cout << min(x, y) << endl;
}

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)*B < (N/C)*D && N%A == 0 && N%C == 0 ) cout<<(N/A)*B<<endl;
 

  if((N/A+1)*B < (N/C)*D && N%A > 0 && N%C == 0) cout<<(N/A+1)*B<<endl;
  

  if((N/A)*B > (N/C+1)*D && N%C > 0 && N%A == 0 ) cout<<(N/C+1)*D<<endl;
  

  if((N/A+1)*B < (N/C+1)*D && N%A > 0 && N%C > 0) cout<<(N/A+1)*B<<endl;
 
  if((N/A)*B > (N/C)*D && N%A == 0 && N%C == 0 ) cout<<(N/C)*D<<endl;
 

  if((N/A+1)*B > (N/C)*D && N%A > 0 && N%C == 0) cout<<(N/C)*D<<endl;
  

  if((N/A)*B < (N/C+1)*D && N%C > 0 && N%A == 0 ) cout<<(N/A)*B<<endl;
  

  if((N/A+1)*B > (N/C+1)*D && N%A > 0 && N%C > 0) cout<<(N/C+1)*D<<endl;

  return 0;
}

C++: #include <stdio.h>
int main(){
    int n,a,b,c,d,x,y;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    for(int i=1;;i++){
        if(n<=x*i){
            x=b*i;
            break;
        }
    }
    for(int j=1;;j++){
        if(n<=c*j){
            y=d*j;
            break;
        }
    }
    if(x<y){
        printf("%d\n",x);
    } else {
        printf("%d\n",y);
    }
}

C++: #include <math.h>
#include <iostream>
using namespace std;
double N, A, B, C, D;
int main() {
  cin >> N >> A >> B >> C >> D;
  cout << (int)min(B * ceil(N / A), D * ceil(N / C)) << '\n';
  return 0;
}

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

C++: #include <iostream>
 
using namespace std;
 
int N,A,B,C,D;
int X_SET,Y_SET,X_SUM,Y_SUM;
int main(){
cin>>N>>A>>B>>C>>D;
X_SET = N/A;
if(N%A>0)X_SET=X_SET+1;
Y_SET=N/C;
if(N%C>0)Y_SET=Y_SET+1;
X_SUM=B*X_SET;
Y_SUM=D*Y_SET;
if(X_SUM<Y_SUM)cout<<X_SUM<<endl;
else
cout<<Y_SUM<<endl;
return 0;
}

C++: #include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int kai(int n) {
	if (n == 0) {
		return 1;
	}
	else {
		return n * kai(n - 1);
	}
}
int rui(int n) {
	if (n == 0) {
		return 1;
	}
	else {
		return 2 * rui(n - 1);
	}
}
int ord(int n) {
	if (n % 2 == 1) {
		return 0;
	}
	else {
		return 1 + ord(n / 2);
	}
}
int main() {
	int n; int ans = 0;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl << 1;
	}
	else if (n == 3) {
		cout << "0 1 -1" << endl << "-1 0 1" << endl << "1 -1 0" << endl << 1;
	}
	else {
		vector<long long> ko(n);
		vector<vector<int>> hyo(n, vector<int>(n, 0));
		long long ba = 4 * n;
		vector<long long> rba(n);
		rba[0] = 1;
		for (int i = 1; i < n; i++) {
			rba[i] = rba[i - 1] * ba;
		}
		for (int i = 1; i < n; i++) {
			if (2 * i < n) {
				hyo[0][i] = 1;
				hyo[i][0] = -1;
			}
			else {
				hyo[0][i] = -1;
				hyo[i][0] = 1;
			}
			for (int j = i + 1; j < n; j++) {
				hyo[i][j] = 1;
				hyo[j][i] = -1;
			}
			ko[i] = n + 1 - 2 * i;
			if (ko[i] <= 0) {
				ko[i] -= 2;
			}
		}
		long long koin = 0;//koin <=ba no n jou//36no9jou
		for (int i = 0; i < n; i++) {
			koin += ko[i] * rba[i];
		}
		int bi = ((n - 1)*(n - 2)) / 2;
		vector<int> jit(bi);
		vector<int> jim(bi);
		int xx = 0;
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				jit[xx] = i;
				jim[xx] = j;
				xx++;
			}
		}
		int cha;
		int chx;
		int chy;
		int jou = rui(bi);
		vector<long long> jan(rui(20));
		vector<int> zer(n, 0);
		vector<int> mju0((n - 1) / 2);
		vector<int> mju1((n - 1) / 2);
		for (int i = 1; 2 * i < n; i++) {
			mju0[i - 1] = i; mju1[i - 1] = i + ((n - 1) / 2);
		}
		vector<int> ju0 = mju0; vector<int> ju1 = mju1;
		for (int i = 1; i < jou; i++) {
			cha = ord(i);
			chx = jit[cha];
			chy = jim[cha];
			long long x = hyo[chx][chy];
			long long two = 2;
			koin -= x * two * rba[chx];
			koin += x * two * rba[chy];
			hyo[chx][chy] = -x;
			hyo[chy][chx] = x;
			if (koin == 0) {
				vector<vector<int> > qhyo;
				int uni = 1;
				long long kaz = 0;
				ju0 = mju0; ju1 = mju1;
				for (int j = 0; j < kai((n - 1) / 2) and uni == 1; j++) {
					for (int k = 0; k < kai((n - 1) / 2) and uni == 1; k++) {
						vector<int> jun(n, 0);
						for (int i = 1; i < n; i++) {
							if (2 * i < n) {
								jun[i] = ju0[i - 1];
							}
							else {
								jun[i] = ju1[i - (n + 1) / 2];
							}
						}
						long long qkaz = 0;
						for (int x = 0; x < n; x++) {
							for (int y = 0; y < n; y++) {
								qkaz = qkaz * 2 + (hyo[jun[x]][jun[y]]);
							}
						}
						if (j == 0 and k == 0) {
							kaz = qkaz;
						}
						for (int l = 0; l < ans; l++) {
							if (qkaz == jan[l]) {
								uni = 0;
							}
						}
						next_permutation(ju1.begin(), ju1.end());
					}
					next_permutation(ju0.begin(), ju0.end());
				}
				if (uni == 1) {
					jan[ans] = kaz;
					ans++;
				}
			}
		}
		cout << ans << endl;
		cin >> n;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  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>

int calculateMin(const int& N, const int& A, const int& B, const int& C, const int& D) {
	int ret;
	int x_price = B;
	int y_price = D;
	int total_x_price, total_y_price;

	int i = 0;
	do {
		i++;
		total_x_price = i*x_price;
	} while ( i*A < N);

	 i = 0;
	do {
		i++;
		total_y_price = i*y_price;
	} while (i*C < N);

	if (total_x_price < total_y_price)
	{
		ret = total_x_price;
	}
	else {
		ret = total_y_price;
	}
	return ret;
}

int main() {

	int N, A, B, C, D;
	std::cin >> N;
	std::cin >> A;
	std::cin >> B;
	std::cin >> C;
	std::cin >> D;

	auto min = calculateMin(N, A, B, C, D);
	std::cout << min << std::endl;
	return 0;
}