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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 998244353;

int main()
{
  int n;
  cin >> n;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ca = ((n - 1) / a + 1) * b, cb = ((n - 1) / c + 1) * d;
  cout << min(ca, cb) << 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(int((n-0.5)/a+1)*b,int((n-0.5)/c+1)*d) << endl;
}

C++: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    long long int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    cout << min((N / A + (N % A != 0)) * B, (N / C + (N % C != 0)) * D) << endl;
    return 0;
}

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

int main(){
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    int ans1,ans2;
    if(N%A==0){
        ans1=N/A;
    }else{
        ans1=1+N/A;
    }
    if(N%C==0){
        ans2=N/C;
    }else{
        ans2=1+N/C;
    }
    ans1*=B;
    ans2*=D;
    cout<<min(ans1,ans2)<<endl;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cl(int a, int b) {
	return (a - (a%b)) / b;//b=0だと積む
}
int up(int a, int b) {
	return cl(a + b - 1, b);//b=0だと積む
}
int main() {
	int n, a, b, c, d, k, l;
	cin >> n >> a >> b >> c >> d;
	k = up(n,a);
	l = up(n,c);
	if (k*b >= l * d) {
		cout << l * d << endl;
	}
	else {
		cout << k * b<<endl;
	}
}

C++: import java.util.Scanner;

class PenSet{
        int number;
        int value;

        PenSet(int x,int y){
                number = x;
                value = y;
        }
}

class Pencils{
        public static void main(String[] args){
                int val,num,setNum,i,j,min=0;

                Scanner scn = new Scanner(System.in);
                num = scn.nextInt();
                setNum = scn.nextInt();
                val = scn.nextInt();
                PenSet x = new PenSet(setNum,val);
                setNum = scn.nextInt();
                val = scn.nextInt();
                PenSet y = new PenSet(setNum,val);

                for(i=-1;i*x.number<num;i++){
                        for(j=0;(i+1)*x.number+j*y.number<num;j++);
                        if(i==-1||((i+1)*x.value + j*y.value)<min)
                                min=((i+1)*x.value + j*y.value);
                }

                System.out.println(min);

        }
}

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

using namespace std;

int main(void)
{
	int N,A,B,C,D,Ahako,Chako;
	cin>>N>>A>>B>>C>>D;
	if(N%A==0){
		Ahako=N/A;
	}else{
		Ahako=N/A+1;
	}
	if(N%C==0){
		Chako=N/C;
	}else{
		Chako=N/C+1;
	}
	if(Ahako*B<=Chako*D){
		cout<<Ahako*B<<endl;
	}else{
		cout<<Chako*D<<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;
  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<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 = true;
  int kane = 0;
  int honsu = 0;
  for(int i=0; i<N/C + 1; ++i){
    int k;
    for(k=1; k<N/A + 2; ++k){
      honsu += A;
      kane += B;
      if(honsu >= N){
	if(first_f){
	  first_f = false;

	  min = kane;
	  break;
	}else{
	  if(min > kane){
	    min = kane;
	  }
	  break;
	}
      }
    }
    honsu -= k * A;
    honsu += C;
    kane -= k * B;
    kane += D;

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

  cout << min << endl;
  return 0;
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){

	int n, a, b, c, d, e, f;
	cin>>n>>a>>b>>c>>d;
	if(n % a == 0) e = n / a * b;
	if(n % a != 0) e = (n / a + 1) * b;
	if(n % c == 0) f = n / c * d;
	if(n % c != 0) f = (n / c + 1) * d;
	if(e > f) cout<<f<<endl;
	if(e <= f) cout<<e<<endl;

	return 0;
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  
  int x,y;
  x=(n/a+1-(n%a==0))*b;
  y=(n/c+1-(n%c==0))*d;
  
  cout<<((x>y) ? y : x)<<en
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


long long int comb(int a, int b) {
	long double ans=1;
	for (int i = 0; i < a-b; ++i) {
		ans*=a-i;
	}

	for (int i = 0; i < a - b; ++i) {
		ans/=i+1;
	}

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