Go: package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)
func main2(){
ans(10,3,50,4,60)
ans(10 ,3, 100, 5, 180)//360
ans(6, 2, 200, 3, 300)// 600

}

func main() {



    sc := bufio.NewScanner(os.Stdin)
     sc.Scan()
        args := strings.Split(sc.Text(), " ")
      

	var n, a, b, c, d int

	n, _ = strconv.Atoi(args[0])
	a, _ = strconv.Atoi(args[1])
	b, _ = strconv.Atoi(args[2])
	c, _ = strconv.Atoi(args[3])
	d, _ = strconv.Atoi(args[4])

        ans(n,a,b,c,d)
}

func ans(n,a,b,c,d int){

	ans2 := 0
	for i := 0; i < 1000; i++ {
		if i*a >= n {
			ans2 = i * b
			break
		}
	}

	for i := 0; i < 1000; i++ {
	
		if i*c >= n {
			if ans2 > i*d {


				ans2 = i *  d
			}
			break
		}
	}

	fmt.Printf("%d\n", ans2)
}

C++: /*JOI 君は鉛筆を N 本買うために近くの文房具店に行くことにした． 
  文房具店では鉛筆が一定の本数ずつのセットで売られている．セット X は A 本で B 円，セット Y は C 本で D 円である． 
  JOI 君はセット X かセット Y の一方を選び，選んだセットをいくつか購入する．
  両方のセットを購入することはできない．N 本以上の鉛筆を得るために必要な金額の最小値を求めよ.*/
#include<iostream>
using namespace std;
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    if((n+a-1)/a*b<=(n+c-1)/c*d){
      cout<<(n+a-1)/a*b<<endl;
    }
    else{
        cout<<(n+c-1)/c*d<<endl;
    }
}

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

int main()
{
  int n,a,b,c,d;
  int num1,num2;

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

  if(n % a == 0 && n % c == 0)
    {
      if((n/a)*b < (n/c)*d)
	{
	  cout << (n/a)*b << endl;
	}
      else
	{
	  cout << (n/c)*d << endl;
	}
    }
  else if(n % c == 0)
    {
      num1= (n/a)+1;
      if(num1*b < (n/c)*d)
	{
	  cout << num1*b << endl;
	}
      else
	{
	  cout << (n/c)*d << endl;
	}
    }
  else if(n % a == 0)
    {
      num2= (n/c)+1;
      if((n/a)*b < num2*d)
	{
	  cout << (n/a)*b << endl;
	}
      else
	{
	  cout << num2*d << endl;
	}
    }
  else
    {
      num1= (n/a)+1;
      num2= (n/c)+1;
      if(num1*b < num2*d)
	{
	  cout << num1*b << endl;
	}
      else
	{
	  cout << num2*d << endl;
	}
    }
}

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

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