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++: #include<bits/stdc++.h>
using namespace std;


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

  cin >> N >> A >> B >> C >> D;

  if(N%A == 0){
  min = N/A * B;
  }
  else {
    min = (N/A + 1) * B;
  }

  if(N%C == 0){
    if(min > N/C*D){
      min = N/C * D;
    }
  }
  else {
    if(min > (N/C + 1) * D){
      min = (N/C + 1) * D;
    }
  }

  
  cout << min << endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int kai(int n) {
	if (n == 0) {
		return 1;
	}
	else {
		return n * kai(n - 1);
	}
}
int he(int a, int b) {
	return a * 3 + b;
}
int main() {
	int n = 9;
	vector<vector<int>> hyo(n,vector<int> (n));
	vector<vector<int>> qhyo;
	int uni = -1;
	vector<int> mju0((n - 1) / 2);
	vector<int> mju1((n - 1) / 2);
	int ans = 15;
	for (int i = 1; 2 * i < n; i++) {
		mju0[i - 1] = i; mju1[i - 1] = i + ((n - 1) / 2);
	}
	vector<int> ju0((n - 1) / 2);
	vector<int> ju1((n - 1) / 2);
	ju0 = mju0;
	ju1 = mju1;
	vector<int> jan = {253164479,253189607,252163902,252964761,227495855,253083033,227006135,227403253,227801299,228187986,228482510,227004074,227273433,165328076,164579227};
	int type;
	cout << "type" << "はいくつ";
	cin >> type;
	vector<vector<int>> cy(11,vector<int> (11));
	for (int i = 0; i < 11; i++) {
		cy[i][i] = 0;
		for (int j = (i + 1) % 11; j != i; j = (j + 1) % 11) {
			if ((j - i + 11) % 11 <= 5) {
				cy[i][j] = 1;
			}
			else {
				cy[i][j] = -1;
			}
		}
	}
	while (type != -1) {
		uni = -1;
		if (type == 0) {
			int c, d;
			cout << "c,d"<<"はいくつ";
			cin >> c >> d;//2 3->2,2 6->13,(7 3,7 6)-> 14
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					vector<int> v(9);
					int x = (i - j + 9) % 9;
					if (x == 1 or x == 4 or x == c or x == d) {
						hyo[i][j] = -1;
					}
					else if (x == 0) {
						hyo[i][j] = 0;
					}
					else {
						hyo[i][j] = 1;
					}
				}
			}
		}
		if (type == 1) {
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					vector<int> v(9);//14
					for (int k = 0; k < 3; k++) {
						v[he((i + 1) % 3, k)] = 1;
						v[he((i + 2) % 3, k)] = -1;
					}
					v[he(i, j)] = 0;
					v[he(i, (j+ 1) % 3)] = 1;
					v[he(i, (j + 2) % 3)] = -1;
					hyo[he(i, j)] = v;
				}
			}
		}
		if (type == 2) {
			int c, d;
			cout << "c,d" << "はいくつ";
			cin >> c >> d;
			vector<int> ji(11);
			ji[0] = 0; ji[c] = 0; ji[d] = 0;
			int th = 1;
			for (int i = 1; i < 11; i++) {
				if (i != c and i != d) {
					ji[i] = th;
					th++;
				}
			}
			hyo[0][0] = 0;
			for (int i = 0; i < 11; i++) {
				if (ji[i] != 0) {
					int xx = cy[i][0] + cy[i][c] + cy[i][d];
					if (abs(xx) == 3) {
						uni = 100;
					}
					else {
						hyo[ji[i]][0] = xx;
						hyo[0][ji[i]] = -xx;
					}
					for (int j = 0; j < 11; j++) {
						if (ji[j] != 0) {
							hyo[ji[i]][ji[j]] = cy[i][j];
						}
					}2
				}
			}
		}
		for (int ty = 0; ty < n and uni < 0; ty++) {
			if (ty == 0) {
				qhyo = hyo;
			}
			vector<int> ti1((n - 1) / 2);
			vector<int> ti2((n - 1) / 2);
			int xy = 0;
			int xz = 0;
			for (int i = 0; i < n; i++) {
				if (qhyo[ty][i] == 1) {
					ti1[xy] = i;
					xy++;
				}
				else if (ty != i) {
					ti2[xz] = i;
					xz++;
				}
			}
			vector<int> ti(n, ty);
			for (int i = 1; i < n; i++) {
				if (2 * i < n) {
					ti[i] = ti1[i - 1];
				}
				else {
					ti[i] = ti2[i - ((n + 1) / 2)];
				}
			}
			for (int j = 0; j < n and uni<0; j++) {
				for (int k = 0; k < n; k++) {
					hyo[j][k] = qhyo[ti[j]][ti[k]];
				}
				for (int j = 0; j < kai((n - 1) / 2) and uni<0; j++) {
					for (int k = 0; k < kai((n - 1) / 2) and uni<0; 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 = 1; x < n; x++) {
							for (int y = x + 1; y < n; y++) {
								qkaz = qkaz * 2 + (((hyo[jun[x]][jun[y]]) + 1) / 2);
							}
						}
						for (int l = 0; l < ans; l++) {
							if (qkaz == jan[l]) {
								uni = l;
							}
						}
						next_permutation(ju1.begin(), ju1.end());
					}
					next_permutation(ju0.begin(), ju0.end());
				}
			}
			ju0 = mju0; ju1 = mju1;
		}
		cout << uni<<endl<<"typeはいくつ？";
		cin >> type;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <functional>
#include <cmath>
#include <map>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

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>
using namespace std;
int main(){
int n,a,b,c,d;
cin >> n >> a >> b >> c >> d;
if (n%a==0,n%c==0){
	if(n/a*b>=n/c*d){
		cout << n/a*b <<endl;
}
	else cout << n/c*d <<endl;
if (n%a==0,n%c!=0){
	if(n/a*b>=(n/c+1)*d){
		cout << n/a*b <<endl;
}
	else cout << (n/c+1)*d <<endl;
if (n%a!=0,n%c!=0){
	if((n/a+1)*b>=(n/c+1)*d){
		cout << (n/a+1)*b <<endl;
}
	else cout << (n/c+1)*d <<endl;
if (n%a!=0,n%c==0){
	if((n/a+1)*b>=n/c*d){
		cout << (n/a+1)*b <<endl;
}
	else cout << n/c*d <<endl;
}
}
}
}
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <string>
#include <map>
#include <math.h>
using namespace std; 
int main(){
	double  N, A, B, C ,D;
	cin >> N >> A >> B >> C >> D;
	double X = ceil(N/A);
	double Y = ceil(N/C);
	if(X*B <= Y*D){
		cout << X*B << endl;
	}
	else{
		cout << Y*D << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    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 <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    int x = n/a, y = n/c;
    if(n%a!=0) x++;
    if(n%c!=0) y++;
    x *= b;
    y *= d;
    if(x>y) pr(y);
    else pr(x);
    return 0;}