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(void){
    int N, a, b, c, d, x, y;
    int bm, dm, as;

    cin >> N >> a >> b >> c >> d;
    x = (N/a);
    y = (N%a);
    if (y != 0) x++;
    bm = x * b;
    x = (N/c);
    y = (N%c);
    if (y != 0) x++;
    dm = x * d;
    if (bm > dm) {
        as = dm;
    } else {
        as = bm;
    }

    cout << as << endl;
    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main(){
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
int i=b;
int ss=c,s=e;
while(i<a){
 i=i+b;
 ss=ss+c;
}
int j=d;
while(j<a){
j=j+d;
s=s+e;
}
cout<<min(s,ss)<<endl;
}

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

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

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,a,b,c,d,i,sum[3]={0},cnt=0;
cin>>n>>a>>b>>c>>d;
while(1){
	sum[1]=sum[1]+b;
	cnt=cnt+a;
	if(cnt>=n){
	break;
	}
}
cnt=0;
while(1){
	sum[2]=sum[2]+d;
	cnt=cnt+c;
	if(cnt>=n){
	break;
	}
}
if(sum[1]<=sum[2]){
printf("%d\n",sum[1]);
}
else{
printf("%d\n",sum[2]);
}
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 AN = N/A+1;
    int CN = N/C+1;
    cout << min(AN*B,CN*D) << endl;
    return 0;
}

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

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

int main(){

    int N,A,B,C,D,sum1,sum2;
    sum1 = 0;
    sum2 = 0;
    cin>>N>>A>>B>>C>>D;
       for (int i=0;i<N;i+A){
            sum1 = sum1+B;
       }
       for (int n=0;n<N;n+C) {
            sum2 = sum2+D;
       }
       if(sum1>=sum2) {
            cout<<sum2+D<<endl;
       } else if(sum1<sum2){
            cout<<sum1+B<<endl;
       }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    double n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    cout<<min((ceil(n/a)*b),(ceil(n/c)*d))<<endl;
}

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

using namespace std;

int n, a, b, c, d;

int main(){
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	
	printf("%d\n", min((int)ceil(n * 1.0 / a) * b, (int)ceil(n * 1.0 / c) * d));
}

C++: #include <iostream>
 
using namespace std;
 
int N,A,B,C,D;
int x , y , xsum , ysum;

int main(){
cin>>N>>A>>B>>C>>D;
x=N/A;
   if(N%A>0) x=x+1;
y=N/C;
   if(N%C>0) y=y+1;
xsum=B*x;
ysum=D*y;
   if(xsum<ysum)cout<<xsum<<endl;
   else
   cout<<ysum<<endl;

return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	double n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	int x=((((n/a)*1000)+999)/1000);
	int  y=((((n/c)*1000)+999)/1000);
	int ans=min(x*b,y*d);
	cout<<ans<<endl;
	//cout<<x<<endl;
	//cout<<y<<endl;
}

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

C++: #include<iostream>
#include<cmath>
using namespace std;
int main() {
    int n, a, an, b, bn;
    cin >> n >> an >> a >> bn >> b;
    double x = (double)n/an, y = (double)n/bn;
    x++; y++;
    int tmpa = 0, tmpb = 0;
    for (int i = 1; i <= (int)x; i++) {
        if ( i == x) break; //x == int
        tmpa += a;
    }
    for (int i = 1; i <= (int)y; i++) {
        if ( i == y) break;
        tmpb += b;
    }
    int ans = (tmpa > tmpb) ? tmpb : tmpa;
    cout << ans << 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;
  
  if((N/A)*B > (N/C)*D) cout<<(N/A)*B<<endl;
  else cout<<(N/C)*D<<endl;

  return 0;
}

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

    if(total_X>total_Y) cout << total_Y << endl;
    else cout << total_X << endl;
    return 0;
}

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

using namespace std;

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

	int money[2] =
	{
		ceil(N / A) * B,
		ceil(N / C) * D
	};

	if (money[0] < money[1])
	{
		cout << money[1] << endl;
	}
	else
	{
		cout << money[0] << 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)を求める
    Xset = N / A + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Xprice = Xset * B ;


    // セットYで揃えた場合のの必要セット数(Yset)を求める
    Yset = N / C + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Yprice = Yset * D ;

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

 return 0;

 }

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  int ans1 = b * (n / a), ans2 = d * (n / c);
  if(n % a != 0) ans1 += b;
  if(n % c != 0) ans2 += d;
  cout << min(ans1, ans2) << endl;
  return 0;
}