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<stdio.h>
#include<math.h>
int main(void){
    int N,A,B,C,D;
    scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
    double x=ceil(N/A);
    double y=ceil(N/C);
    if (B*x <= D*y)
{printf("B*x\n");}
else{printf("D*y\n");}
return 0;
}

C++: // Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  double N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  cout << (int)min(ceil(N/A)*B, ceil(N/C)*D) << endl;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	int x, y;
	if (N%A == 0)x = B * N / A;
	else x = B * (N / A + 1);
	if (N%C == 0)y = D * N / C;
	else y = D * (N / C + 1);
	if (x <= y)cout << x << endl;
	else cout << y << endl;
	cin >> N;
}

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

int main() {
int N,A,B,C,D,E,F;
cin >> N >> A >> B >> C >> D;
   E = (N/A)*B;
   F = (N/C)*D;
   if(A > C){
       cout<< E <<endl;
  } 
   if(A<C){
        cout<< F << endl;
  }
  return 0;

}

C++: #include <iostream>
using namespace std;
int main(void){
    int n,a,b,c,d;
    int x,y;
    cin >> n,a,b,c,d;
    
    x=n/a;
    if(x!=1) x++;
    x=x*c;

    y=n/b;
    if(y!=1) y++;
    y=y*d;

    if(x<y){
     count << x;
    }else{
     count << y;
    }

return 0;
    
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641


#include<iostream>
 using namespace std; //標準名前空間を使用

int main(){

    //変数を読み込む
    int N , A , B ,C ,D ;
    int Xset , Yset , Xprice , Yprice;

    cin >> N >> A >> B >> C >> D ; //変数の読み込み

    // セットXで揃えた場合の必要セット数(Xset)を求める
    if( N % A == 0){
        Xset = N / A ;
    }else{
        Xset = N / A + 1 ;
    }

    // セットXで揃えた場合の合計金額を求める
    Xprice = Xset * B ;


    // セットYで揃えた場合の必要セット数(Yset)を求める

    if( N % C == 0){
        Yset = N / C ;
    }else{
        Yset = N / C + 1 ;
    }

    // セットXで揃えた場合の合計金額を求める
    Yprice = Yset * D ;

    //XpriceとYpriceを比較する
    if(Xprice < Yprice){
    cout << Xprice ; //XpriceがYpriceより小さい場合、Xpriceを出力
    }else{
    cout << Yprice ; //そうでない場合、Ypriceを出力
    }

 return 0;

 }

 // 注：割り算の繰上げはceilでもできる

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

int main()
{
  int n, a, b, c, d;
  int x_price, y_price;
  std::cin >> n >> a >> b >> c >> d;

  x_price = (n + a - 1) / a * b;
  y_price = (n + c - 1) / c * d;

  std::cout << std::min(x_price, y_price) << std::endl;

  return (0);
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int N,A,B,C,D,N1,N2;
	scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
	if(N%A==0){N1=N/A*B;}else{N1=(N/A+1)*B;}//セットXのときのN本買うための値段
	if(N%C==0){N2=N/C*D;}else{N2=(N/C+1)*D;}
	printf("%d\n",min(N1,N2));
	return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	int ans1 = 0, ans2 = 0;

	int current = n;

	while (current > 0){
		ans1 += b;
		current -= a;
	}

	current = n;

	while (current > 0){
		ans2 += d;
		current -= c;
	}
	cout << (ans1 < ans2 ? ans1 : ans2) << endl;

}

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

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

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c,d,t,k,n,o,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;
}

C++: #include <iostream>
using namespace std;
int main(){
   int n,ryouA=0,neA=0,ryouB=0,neB=0,i,j,hon1=0,hon2=0,ansa=0,ansb=0;
   cin>>n;
       cin>>ryouA>>neA>>ryouB>>neB;
       for(;;){
           hon1=hon1+ryouA;
           ansa+=neA;
           if(hon1>=n){
               break;
           }
           
       }
       for(;;){
           hon2=hon2+ryouB;
           ansb+=neB;
           if(hon2>=n){
               break;
           }
          
       }
   
   if(ansa<=ansb){
           cout<<ansa<<endl;
       }
       else if(ansb<ansa){
           cout<<ansb<<endl;
       }
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d,cnt=0,cnt2=0,pen1=0,pen2=0,cost=0;
	cin>>n>>a>>b>>c>>d;
	while(n>=pen1){
		pen1=pen1+a;
		cnt++;}
	while(n>pen2){
		pen2=pen2+c;
		cnt2++;}
	if(cnt2*d>cnt*b)
		cost=cnt*b;
	if(cnt*b>cnt2*d)
		cost=cnt2*d;
	if(cnt2*d==cnt*b)
		cost=cnt*b;
	cout<<cost<<endl;
	
	return 0;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int kounyu(int h, int y, int k)
{
	int nedan=0;
	while(k>0)
	{
		nedan += y;
		k -= h;
	}
	return nedan;
}
int main(void)
{
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	int ans = min(kounyu(A, B, N), kounyu(C, D, N));
	cout << ans << endl;
}

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