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 ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    cout << min(B * ceil(N * 1.0 / A), D * ceil(N * 1.0 / C)) << endl;
}

C++: #include <iostream>
#include <cstdlib>

using namespace std;

int cost(int n, int x, int y)
{
  int m = int(n/x);
  if(n%x!=0) {
    m += 1;
  }
  return m*y;
}

int main()
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  
  cout << min(cost(n, a, b), cost(n, c, d)) << endl;
  return 0;
}

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

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    cout << min(ceil( (double) n/a)*b, ceil((double) n/c)*d) << endl;
}

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

//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. 
	
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.

//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.






//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.
//I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure. I am a failure.

C++: #include <iostream>

using namespace std;

int main() {

	int n, a, b, c, d;
	int i, j, l;
	int sumA = 0, cnt = 1, sumB = 0;

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

	for (i = a; i <= n; i = i + a-1) {
		sumA = b * cnt;
		cnt++;
	}

	cnt = 1;

	for (i = c; i <= n; i = i + c-1) {
		sumB = d * cnt;
		cnt++;
	}

	if (sumA >= sumB) cout << sumB << endl;
	else cout << sumA << endl;
	
//	cout << sumA <<endl << sumB;

//	cin >> a;

	return 0;
}

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

//x：A本でB円
//y：C本でD円
//xかyを選択
//n本以上を購入

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

	int a_no = ceil((float)n / (float)a);
	int a_price = a_no * b;

	int c_no = ceil((float)n / (float)c);
	int c_price = c_no * d;

	printf("%d\n", a_price < c_price ? a_price : c_price);
}

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

using namespace std;

int FindLeast( int needs, int pieces, int val ) {
    int k = 1;
    while ( k*pieces < needs ) ++k;
    return k*val;
}
main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    cout << min( FindLeast( n, a, b ), FindLeast( n, 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 setsX = (N + A - 1) / A;
	int setsY = (N + C - 1) / C;
	cout << min(B * setsX, D * setsY) << endl;
	return 0;
}

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

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

int main(){

    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    int sum = 0;
    int sum1 = 0;
    for (int i=0;i<N;i=i+A){
       sum = sum+B;
    }
    for (int i=0;i<N;i=i+B){
       sum1 = sum1+D;
    }
    if(sum<=sum1){
      cout<<sum+B<<endl;
    } else {
      cout<<sum+D<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    if(n%a>0)a=n/a+1;
    else a=n/a;
    if(n%c>0)c=n/c+1;
    else c=n/c;
    cout<<min(a*b,c*d)<<endl;
}