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

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;

    // セット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>
 
using namespace std;
 
int N,A,B,C,D;
int X_SET,Y_SET,X_SUM,Y_SUM;
int main(){
cin>>N>>A>>B>>C>>D;
X_SET = N/A;
if(N%A>0)X_SET=X_SET+1;
Y_SET=N/C;
if(N%C>0)Y_SET=Y_SET+1;
X_SUM=B*X_SET;
Y_SUM=D*Y_SET;
if(X_SUM<Y_SUM)cout<<X_SUM<<endl;
else
cout<<Y_SUM<<endl;
return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define RS resize

int main()
{
	int a, A, b, B, N;
	cin >> N >> a >> A >> b >> B;
	int x, y;
	x = ((a + N - 1) / a) * A;
	y = ((b + N - 1) / b) * B;
	cout << min(x, y) << endl;
}

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


int main(){
   int N,A,B,C,D;
   cin>>N>>A>>B>>C>>D;
  
  if((N/A)*B < (N/C)*D && N%A == 0 && N%C == 0 ) cout<<(N/A)*B<<endl;
 

  if((N/A+1)*B < (N/C)*D && N%A > 0 && N%C == 0) cout<<(N/A+1)*B<<endl;
  

  if((N/A)*B > (N/C+1)*D && N%C > 0 && N%A == 0 ) cout<<(N/C+1)*D<<endl;
  

  if((N/A+1)*B < (N/C+1)*D && N%A > 0 && N%C > 0) cout<<(N/A+1)*B<<endl;
 
  if((N/A)*B > (N/C)*D && N%A == 0 && N%C == 0 ) cout<<(N/C)*D<<endl;
 

  if((N/A+1)*B > (N/C)*D && N%A > 0 && N%C == 0) cout<<(N/C)*D<<endl;
  

  if((N/A)*B < (N/C+1)*D && N%C > 0 && N%A == 0 ) cout<<(N/A)*B<<endl;
  

  if((N/A+1)*B > (N/C+1)*D && N%A > 0 && N%C > 0) cout<<(N/C+1)*D<<endl;

  return 0;
}

C++: #include <stdio.h>
int main(){
    int n,a,b,c,d,x,y;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    for(int i=1;;i++){
        if(n<=x*i){
            x=b*i;
            break;
        }
    }
    for(int j=1;;j++){
        if(n<=c*j){
            y=d*j;
            break;
        }
    }
    if(x<y){
        printf("%d\n",x);
    } else {
        printf("%d\n",y);
    }
}

C++: #include <math.h>
#include <iostream>
using namespace std;
double N, A, B, C, D;
int main() {
  cin >> N >> A >> B >> C >> D;
  cout << (int)min(B * ceil(N / A), D * ceil(N / C)) << '\n';
  return 0;
}