Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	N, A, B, C, D := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()

	x := (N + A - 1) / A * B
	y := (N + C - 1) / C * D

	var z int
	if x < y {
		z = x
	} else {
		z = y
	}

	fmt.Println(z)
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    ll ans = INF;
    if (n % a == 0) ans = n / a * b;
    else ans = (n / a + 1) * b;

    if (n % c == 0) chmin(ans, n / c * d);
    else chmin(ans, (n / c + 1) * d);

    cout << ans << 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];
					}
				}
			}
		}
		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<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  int a_count = 0;
  int c_count = 0;
  for(int i = 1; i < 1000; i++){
    if(a*i >= n) a_count = a*i; break;
  }
  for(int j = 1; j < 1000; j++){
    if(c*j >= n) c_count = c*j; break;
  }
  cout << min(a_count, c_count) << endl;
}

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


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

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

  bool first_f = false;
  int kane = 0;
  int honsu = 0,counter = 0;
  for(int i=0; i<N/C + 1; ++i){
    for(int k=0; k<N/A + 1; ++k){
      honsu += A;
      kane += B;
      ++counter;
      if(honsu >= N){
	if(!first_f){
	  first_f = true;

	  min = kane;
	}else{
	  if(min > kane){
	    min = kane;

	    break;
	  }
	}
      }
    }
    honsu -= counter * A;
    honsu += C;
    kane -= counter * B;
    kane += D;
    counter = 0;

    if(honsu >= N){
      break;
    }
  }

  cout << kane << endl;
  return 0;
}