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<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;}

C++: /*宣言*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main()
{
	int n, a, b, c, d, ans = 0,x,y;
	cin >> n >> a >> b >> c >> d;
	x = n / a;
	y = n / c;
	if (n%a != 0)
		x++;
	if (n%c != 0)
		y++;
	ans = min(b*x, d*y);
	cout << ans << endl;
	return 0;
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  int ans = min((N + A - 1) / A * B, (N + C - 1) / C * D);
  cout << ans << "\n";
  return 0;
}