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++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
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>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	
	cout << std::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,a,b;
	cin>>N>>A>>B>>C>>D;
	a=N/A*B;
	b=N/C*D;
	if(N%A!=0)a=a+B;
	if(N%C!=0)b=b+D;
	if(a<b){
		cout<<a<<endl;
	}else{
		cout<<b<<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 sa = (n % a == 0 ? n / a : n / a + 1) * b;
	int sb = (n % c == 0 ? n / c : n / c + 1) * d;
	cout << min(sa, sb) << endl;
	return 0;
}

C++: #include <stdio.h>

int CalcTotalVal(int iTargetNumber, int iSetNumber, int iSetValue);

int main(int argc, char *argv[])
{
    // 条件を入力してもらう
    int iTargetNumber = 0, iSetANumber = 0, iSetAValue = 0, iSetBNumber = 0, iSetBValue = 0;
    scanf("%d %d %d %d %d",&iTargetNumber,&iSetANumber,&iSetAValue,&iSetBNumber,&iSetBValue);
    
    // ASet、BSetの必要金額を計算
    int iSetATotalVal = 0, iSetBTotalVal = 0;
    iSetATotalVal = CalcTotalVal(iTargetNumber, iSetANumber, iSetAValue);
    iSetBTotalVal = CalcTotalVal(iTargetNumber, iSetBNumber, iSetBValue);
    
    // 安い方を出力
    int iAnsVal = 0;
    if(iSetATotalVal < iSetBTotalVal){
        iAnsVal = iSetATotalVal;
    }
    else{
        iAnsVal = iSetBTotalVal;
    }
    printf("%d\n", iAnsVal);

    return 0;
}

int CalcTotalVal(int iTargetNumber, int iSetNumber, int iSetValue)
{
    int iSetCount = 0;
    if(iSetNumber != 0){
        iSetCount = iTargetNumber / iSetNumber;
        if(iTargetNumber % iSetNumber != 0){
            iSetCount += 1;
        }
    }
    return iSetValue * iSetCount;
}

C++: #include<iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N, A, B, C, D, X, Y, i = 0, j = 0, a = 0, b = 0;
    cin >> N >> A >> B >> C >> D;
    X = B;
    Y = D;
    while (N > a)
    {
        a += A;
        i++;
    }
    while (N > b)
    {
        b += C;
        j++;
    }
    X *= i;
    Y *= j;
    if (X < Y)
        cout << X << endl;
    else
        cout << Y << 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;
	cout << min((N + A - 1) / A * B, (N + C - 1) / C * D) << endl;
	return 0;
}

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

using namespace std;

int main() {
	int n, a, b, c, d, totalX, totalY;

	cin >> n >> a >> b >> c >> d;
	totalX = (n / a + (n%a == 0 ? 0 : 1)) * b;
	totalY = (n / c + (n%c == 0 ? 0 : 1)) * d;
	cout << min(totalX, totalY) << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int N,A,B,C,D;
int 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;
}

C++: #include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int setA = n / a;
  int setB = n / c;
  int pa, pb;
  if (n % a == 0) {
    pa = setA * b;
  } else {
    setA++;
    pa = setA * b;
  }
  if (n % c == 0) {
    pb = setB * d;
  } else {
    setB++;
    pb = setB * d;
  }
  cout << min(pa, pb) << endl;
}

C++: #include<stdio.h>
int main()
{
int N,A,B,C,D,hoge=0,sushi=0;
scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
if(N%A!=0){
hoge=N/A;
hoge=hoge+1;
}else{
hoge=N/A;
}
if(N%C!=0){
sushi=N/C;
sushi=sushi+1;
}else{
sushi=N/C;
}
B=hoge*B;
D=sushi*D;
if(B<=D){
printf("%d\n",B);
}else if(D<=B){
printf("%d\n",D);
}
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==0) a=n/a;
  else a=n/a+1;
  if(n%c==0) c=n/c;
  else c=n/c+1;
  if(a*b>c*d) cout<<c*d<<endl;
  else cout<<a*b<<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 moneyX = ( ((int)N / A) + (N % A != 0) ) * B;
	int moneyY = ( ((int)N / C) + (N % C != 0) ) * D;

	cout << min(moneyX, moneyY) << endl;

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int N,A,B,C,D,a,b;
	cin>>N>>A>>B>>C>>D;
	a=N/A*B+N%A*B;
	b=N/C*D+N%C*D;
	if(a<b){
		cout<<a<<endl;
	}else{
		cout<<b<<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=1; i<N/C + 2; ++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<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int N,A,B,C,D,x,y;
    cin>>N>>A>>B>>C>>D;
    x=ceil((double)N/A)*B;
    y=ceil((double)N/C)*D;
    
    
    
    
    
    cout<<min(x,y)<<endl;
    return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,A,B,C,D;
	scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);

	int X_num,Y_num,X_sum,Y_sum;

	if(N%A == 0){
		X_num = N/A;
	}else{
		X_num = N/A+1;
	}

	X_sum = B*X_num;

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

	Y_sum = D*Y_num;

	printf("%d\n",min(X_sum,Y_sum));

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;
 
int main() {
	int a, b, c, d, e;
	int needb = 0, needd = 0;
	cin >> a >> b >> c >> d >> e;
	
	if (a%b == 0) {
		needb = a / b;
	}
	else {
		needb = (a / b) + 1;
	}
 
	if (a%d == 0) {
		needd = a / d;
	}
	else {
		needd = a / d + 1;
	}
 
	cout << min(needb * c, needd * e) << endl;
 
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  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;
}