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>

using namespace std;

int cunting(int cunt,int n){
  int t;
  t = 0;
  int i;
  for( i = 0;t < n;i++){
    t += cunt;
  }
  return i;
}

typedef struct{
  int num;
  int value;
}pencil;

int main(){
  pencil a1;
  pencil a2;
  int N;

  cin >> N;
  cin >> a1.num >> a1.value;
  cin >> a2.num >> a2.value;

  int c1,c2;

  c1 = cunting(a1.num,N);
  c2 = cunting(a2.num,N);


  cout << min(a1.value*c1,a2.value*c2) << endl;
}

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 = false;
  int kane = 0;
  int honsu = 0,counter = 0;
  for(int i=0; i<N/C + 2; ++i){
    for(int k=0; k<N/A + 2; ++k){
      honsu += A;
      kane += B;
      ++counter;
      if(honsu >= N){
	if(!first_f){
	  first_f = true;

	  min = kane;
	  break;
	}else{
	  if(min > kane){
	    min = kane;
	  }
	  break;
	}
      }
    }
    honsu -= counter * A;
    honsu += C;
    kane -= counter * B;
    kane += D;
    counter = 0;

    if(honsu >= N){
      if(min > kane){
        min = kane;
      }
      break;
    }
  }

  cout << kane << endl;
  return 0;
}

C++: // Pencils 2018/12/27

#include <cstdio>
using namespace std;

int main() {
    int N, A, B, C, D;
    int x, y;

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

    x = (N / A) * B;
    if (N % A) x += B;

    y = (N / C) * D;
    if (N % C) y += D;

    if (x <= y) printf("%d\n", x);
    else printf("%d\n", y);

    return 0;
}

C++: #include <iostream>

int main(){
    int N,A,B,C,D;
    std::cin>>N>>A>>B>>C>>D;
    
    int X=N/A;
    if(N%A!=0) X++;
    int Y=N/C;
    if(N%C!=0) Y++;  

    X=X*B;
    Y=Y*D;
    if(X<=Y) std::cout<<X<<"\n";
    else std::cout<<Y<<"\n";

    return 0;
}

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++: #include<iostream>
int main()
{
	int N, A, B, C, D;
	std::cin >> N >> A >> B >> C >> D;
	int ans1, ans2;
	if (N%A != 0) {
		ans1 = (N / A + 1)*B;
	}
	else if(N%A==0){
		ans1 = N / A * B;
	}
	if (N%C != 0) {
		ans2 = (N / C + 1)*D;
	}
	else if(N%C==0){
		ans2 = N / C * D;
	}
	if (ans1 > ans2) {
		std::cout << ans2 << std::endl;
	}
	else if (ans2 > ans1) {
		std::cout << ans1 << std::endl;
	}
	else {
		std::cout << ans1 << std::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;
	b=N/C*D+D;
	if(a<b){
		cout<<a<<endl;
	}else{
		cout<<b<<endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

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

    int ans;
    ans=(N+A-1)/A*B;
    ans=min(ans,(N+C-1)/C*D);

    cout<<ans<<endl;
	
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
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;
}

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 + 1; ++i){
    int k;
    for(k=1; k<N/A + 1; ++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>
int main(){
    int n,a,b,c,d;
    std::cin>>n>>a>>b>>c>>d;
    
    int cnt1,cnt2,pri1,pri2;
    if(n%a==0){
        cnt1=n/a;
        pri1=cnt1*b;
    }else{
        cnt1=(n/a)+1;
        pri1=cnt1*b;
    }
    if(n%c==0){
        cnt2=n/c;
        pri2=cnt2*d;
    }else{
        cnt2=(n/c)+1;
        pri2=cnt2*d;
    }
    if(pri1<=pri2){
        std::cout<<pri1<<"\n";
    }else{
        std::cout<<pri2<<"\n";
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int h = 0, sk = 0, tk = 0;
  while(h < n) h += a, sk += b;
  h = 0;
  while(h < n) h += c, tk += d;
  cout << min(sk, tk) << endl;
}

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


using namespace std;

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

    int mA , mC;
    int pB=0, pD=0;
    for(int i=1; i<=1000;i++){
        mA = A*i;
        if(N<=mA){
            pB = i*B;
            break;
        }

    }
    for(int i=1; i<=1000;i++){
        mC = C*i;
        if(N<=mC){
            pD = i*D;
            break;
        }

    }
    if(pD > pB){
        printf("%d\n",pB);
    }
    else{
        printf("%d\n",pD);
    }
    return 0;
}

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

using namespace std;

#define	MIN(X, Y)	X < Y ? X : Y

struct SET{
	int pen_n;
	int yen;
};

int main()
{
	int N;
	SET X, Y;
	int x_n, y_n;
	int ans;

	cin >> N >> X.pen_n >> X.yen >> Y.pen_n >> Y.yen;

	x_n = N / X.pen_n;
	if(N % X.pen_n)
		x_n++;

	y_n = N / Y.pen_n;
	if(N % Y.pen_n)
		y_n++;

	ans = MIN(x_n * X.yen, y_n * Y.yen);

	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;
    cout <<min((n+a-1)/a*b , (n+c-1)/c*d)<<endl;
    return 0;

}