Go: package main

import (
	"fmt"
	"math"
)

func price(wantNum int, setNum int, setPrice int) int {
	return int(math.Ceil(float64(wantNum)/float64(setNum))) * setPrice
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, a, b, c, d int
	fmt.Scanf("%d %d %d %d %d", &n, &a, &b, &c, &d)

	var priceA = price(n, a, b)
	var priceB = price(n, c, d)
	var p = min(priceA, priceB)

	fmt.Printf("%d\n", p)
}

C++: #include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
#include <climits>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_T _DEF(T,in,){return in<T>(gcu());}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int p(int n, int a, int b) {
	return (n + a - 1) / a * b;
}

int main() {
	int n {in()}, a {in()}, b {in()}, c {in()}, d {in()};
	outl(min(p(n, a, b), p(n, c, d)));
}

C++: #include<iostream>
using namespace std;
int main(){
	int N,A,B,C,D,a,b;
	cin>>N>>A>>B>>C>>D;
	a=N/A*B+N%A*B;
	b=N/C*D+N%C*D;
	if(a<b){
		cout<<a<<endl;
	}else{
		cout<<b<<endl;
	}
	return 0;
}

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

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

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

using namespace std;

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

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

int main() {
	int n, a, b, c, d,x,y;
	cin  n >> a >> b >> c >> d;
	if (n%a > 0) {
		x = (n / a + 1)*b;
	}
	else {
		x = (n / a)*b;
	}
	if (n%c > 0) {
		y = (n / c + 1)*d;
	}
	else {
		y = (n / c)*d;
	}
	cout << min(x, y) << 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 x = (n + a - 1) / a * b;
  int y = (n + c - 1) / c * d;
  cout << min(x, y) << "\n";
}

C++: #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,A,B,C,D;
  cin>>n>>A>>B>>C>>D;

  int a = ((n-1) / A + 1) * B;
  int b = ((n-1) / C + 1) * D;
  int ans = min(a,b);
  cout<<ans<<endl;
  
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    
    int set_num_x = N / A;
    if (N % A != 0) {
        ++set_num_x;
    }
    
    int set_num_y = N / C;
    if (N % C != 0) {
        ++set_num_y;
    }

    int cost_x = set_num_x * B;
    int cost_y = set_num_y * D;

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

    return 0;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
int n,a,b,c,d;
cin>>n>>a>>b>>c>>d;
int a1=((int)(n/a))*b;
int a2=((int)(n/c))*d;
if(n%a!=0){a1+=b;}
if(n%c!=0){a2+=d;}
	cout<<min(a1,a2)<<endl;
return 0;
}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, a, b, c, d, tmp1, tmp2, tmp3, tmp4;

int main(){

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

	while (n > tmp1) {
		tmp2 += b;
		tmp1 += a;
	}
	while (n > tmp3) {
		tmp4 += d;
		tmp3 += c;
	}
	cout << min(tmp4, tmp2) << endl;



	return 0;
}