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++: // clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int ans = INF;
  for (int x = 0; x <= 1000; x++) {
    for (int y = 0; y <= 1000; y++) {
      int num = a * x + c * y;
      if (num < n) continue;
      cmin(ans, b * x + d * y);
    }
  }
  cout << ans << endl;
}

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

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

using namespace std;

int main(){
	ll n, a, b, c, d, x, y;
	
	cin>>n;
	cin>>a>>b>>c>>d;
	
	x=(n-1)/a;
	y=(n-1)/c;
	x++;
	y++;
	x=x*b;
	y=y*d;
	
	
	cout<<min(x,y)<<"\n";
}

C++: #include <iostream>
#include <algorithm>
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 <iostream>

using namespace std;

int main()
{
  int N, A, B, C, D;
  int number_of_X, number_of_Y;
  
  cin >> N >> A >> B >> C >> D;

  N % A ? number_of_X = N / A + 1 : number_of_X = N / A;
  N % C ? number_of_Y = N / C + 1 : number_of_Y = N / C;

  number_of_X * B <= number_of_Y * D ?
    cout << number_of_X * B << endl : cout << number_of_Y * D << endl;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a, b, c, d;

int main() {
	cin >> n >> a >> b >> c >> d;
	int na = (n / a + (n%a == 0 ? 0 : 1));
	int nc = (n / c + (n%c == 0 ? 0 : 1));
	cout << min(na*b , nc*d) << endl;
}

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

using namespace std;

int main(void)
{
int n,a,b,c,d,k,m,x,y;
cin >> n >> a >> b >> c >> d;
k=n/a;
m=n/c;
if(n>k*a){
k++;}
x=k*b;
if(n>m*c){
m++;}
y=m*d;
if(x>=y){
cout << y << endl;}
else if(x<=y){
cout << x << endl;}
return 0;
}

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

C++: #include<iostream>
#include<algorithm>
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>
#include <algorithm>
using namespace std;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	int X1 = (N + A - 1) / A;
	int X2 = (N + C - 1) / C;
	cout << min(X1 * B, X2 * D) << endl;
	return 0;
}

C++: #include <iostream>

int main() {
  int n, a, b, c, d;

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

  int qty_x = n % a == 0 ? n / a : (n / a) + 1;
  int qty_y = n % c == 0 ? n / c : (n / c) + 1;

  int cost_x = qty_x * b;
  int cost_y = qty_y * d;

  if (cost_x <= cost_y) {
    std::cout << cost_x << std::endl;
  } else {
    std::cout << cost_y << std::endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;


int main(){
    int n,a,b,c,d;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    
    int ans = n / a * b;
    if(n % a != 0){
        ans += b;
    }
    
    if(n % c == 0){
        ans = min(ans,n / c * d);
    }else{
        ans = min(ans,n / c * d + d);
    }

    printf("%d\n",ans);

    return 0;
    
}

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

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