Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()
	d, _ := nextInt()

	costX := b * int(math.Ceil(float64(n)/float64(a)))
	costY := d * int(math.Ceil(float64(n)/float64(c)))
	fmt.Println(min(costX, costY))
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  ll res1, res2;
  if (n%a == 0) {
    res1 = (n/a)*b;
  } else {
    res1 = (n/a)*b + b;
  }
  if (n%c == 0) {
    res2 = (n/c)*d;
  } else {
    res2 = (n/c)*d + d;
  }
  cout << min(res1, res2) << endl;
}

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 <bits/stdc++.h>
using namespace std;

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             


int main(void){
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    
    int tmp[2];
    if( n % a == 0 ) tmp[0] = n / a * b;
    else             tmp[0] = ( n / a + 1 ) * b;
    
    if( n % c == 0 ) tmp[1] = n / c * d;
    else             tmp[1] = ( n / c + 1 ) * d;

    
    cout << min( tmp[0], tmp[1] ) << endl;
}

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

int main(){

  int N,A,B,C,D;
  int sum1=0,sum2=0,ans1,ans2;;

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

  while(1){
    sum1=sum1+A;
    sum2=sum2+B;
    // if(sum1==N){sum2=sum2-B; break; }
    if(sum1>=N){ break; }

  }

  ans1=sum2;


  sum1=0; sum2=0;



 while(1){
    sum1=sum1+C;
    sum2=sum2+D;

    // if(sum1==N){ sum2=sum2-D; break; }
if(sum1>=N){ break; }
  }




  ans2=sum2;
  if(ans1<ans2){
  cout<<ans1<<endl;
  }

  if(ans1>=ans2){
  cout<<ans2<<endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){

	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	//n=必要な本数
	//a=セットxの本数
	//b=セットxの値段
	//c=セットyの本数
	//d=セットyの値段

	int e;
	if(n%a==0){
		e=n/a;
	}
	else{
		e=n/a+1;
	}
	//xを選んだ時のセット数
		e=e*b;
		//xを選んだ時の値段

	int f;
	if(n%c==0){
		f=n/c;
	}
	else{
		f=n/c+1;
	}
	//yを選んだ時のセット数
	f=f*d;
	//yを選んだ時の値段

	if(e<f){
		cout<<e<<endl;
	}
	if(f<=e){
		cout<<f<<endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int N,A,B,C,D,x,y,X,Y;
	cin>>N>>A>>B>>C>>D;

		x=N/A;
		y=x*B;
		X=N/C;
		Y=X*D;

		if(N%A!=0){
			y=y+B;
		}
		if(N%C!=0){
			Y=Y+D;
		}
		if(y>Y){swap(y,Y);}

		cout<<y<<endl;

		return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int A = int(n / a) * b;
    if(n % a != 0) A += b; 
    int C = int(n / c) * d;
    if(n % c != 0) C += d;
    cout << min(A,C) << endl;
}

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

int main(void) {
    int N,A,B,C,D;cin>>N>>A>>B>>C>>D;
    int X = (N % A == 0) ? (N / A) * B: ((N / A) + 1) * B;
    int Y = (N % C == 0) ? (N / C) * D: ((N / C) + 1) * D;
    cout << min(X, Y) << endl;
    return 0;
}

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

C++: #include <stdio.h>

int main(void) {
  int n, a, b, c, d;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  b *= (n + a - 1) / a;
  d *= (n + c - 1) / c;
  printf("%d\n", b < d ? b : d);
  return 0;
}

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

int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    int xset=(n+a-1)/a*b;
    int yset=(n+c-1)/c*d;
    if(xset<yset) cout << xset << endl;
    else cout << yset << endl;
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int i,o,s,t,r,e=1,a=1,m,q;
	cin>>i>>o>>s>>t>>r;
	m=o;
	q=t;
	while(i>m){
		e++;
		m=m+o;
	}
	while(i>q){
		a++;
		q=q+t;
	}
	s=s*e;
	r=r*a;
	if(s<=r){
		cout<<s;
	}else{
		cout<<r<<endl;
	}
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int A,B,C,D;
    cin >> 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 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;
	else cout << sumA;
	
//	cout << sumA <<endl << sumB;

//	cin >> a;

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int N,A,B,C,D;
    int E,F=0;
    cin >> N >> A >>B >> C >> D;
    while(N>A*E){
        E++;
    }
    while(N>C*F){
        F++;
    }
    if(B*E<D*F){
        cout << B*E << "\n";
    }else{
        cout << D*F << "\n";
    }
    return 0;
}

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

int main(void){
  int n,a,b,c,d;
  cin >> n>>a>>b>>c>>d;
  int x_sum=0,y_sum=0,x_buy=0,y_buy=0;
  while(x_buy<n){
  	x_sum+=b;
    x_buy+=a;
  }
  while(y_buy<n){
  	y_sum+=d;
    y_buy+=c;
  }
  if(x_sum<y_sum)cout<<x_sum<<endl;
  else cout << y_sum << endl;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

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