Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()
	d, _ := nextInt()

	costX := b * int(math.Ceil(float64(n)/float64(a)))
	costY := d * int(math.Ceil(float64(n)/float64(c)))
	fmt.Println(min(costX, costY))
}

C++: #include<iostream>
using namespace std;
int main(){
int n,a,b,c,d;
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;
if (n%a==0,n%c!=0){
	if(n/a*b>=(n/c+1)*d){
		cout << n/a*b <<endl;
}
	else cout << (n/c+1)*d <<endl;
if (n%a!=0,n%c!=0){
	if((n/a+1)*b>=(n/c+1)*d){
		cout << (n/a+1)*b <<endl;
}
	else cout << (n/c+1)*d <<endl;
if (n%a!=0,n%c==0){
	if((n/a+1)*b>=n/c*d){
		cout << (n/a+1)*b <<endl;
}
	else cout << n/c*d <<endl;
}
}
}
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <random>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	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++: // 2018/12/17 Tazoe

#include <iostream>
using namespace std;

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

	int X = ((N-1)/A+1)*B;
	int Y = ((N-1)/C+1)*D;

	if(X<=Y){
		cout << X << endl;
	}
	else{
		cout << Y << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

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

    int ansX=(N%A==0?N/A:(N/A)+1)*B;
    int ansY=(N%C==0?N/C:(N/C)+1)*D;

    cout << min(ansX,ansY) << endl;
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,a,b,c,d,e,f,kekka;
    cin>>n>>a>>b>>c>>d;
    if(n%a==0){
        e=n/a;
    }else if(n%a>0){
        e=n/a+1;
    }
    if(n%c==0){
        f=n/c;
    }else if(n%c>0){
        f=n/c+1;
    }
    kekka=min(e*b,f*d);
    cout<<kekka<<endl;
}

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

int main() {
	int n, a, b, c, d,x,y;
	cin  n >> a >> b >> c >> d;
	if (n%a > 0) {
		x = (n / a + 1)*b;
	}
	else {
		x = (n / a)*b;
	}
	if (n%c > 0) {
		y = (n / c + 1)*d;
	}
	else {
		y = (n / c)*d;
	}
	cout >> min(x, y) >> endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower

  return R-L;
}

int main(){
  int n,a,b,c,d,ans=1e9;
  cin>>n>>a>>b>>c>>d;
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++){
      if(i*a+j*c>=n)ans=min(ans,b*i+d*j);
    }
  cout<<ans<<endl;
  return 0;
}

C++: #include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d,n,x,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	if(n%a!=0){
		x++;
	}
	y=n/c;
	if(n%c!=0){
		y++;
	}
	if(b*x<d*y){
		printf("%d\n",b*x);
	}
	else{
		printf("%d\n",d*y);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;
int main()
{
    int n, a, b, c, d, x, y;
    cin >> n >> a >> b >> c >> d;
    if (n % a == 0)
    {
        x = n / a * b;
    }
    else
    {
        x = (n / a + 1) * b;
    }
    if (n % c == 0)
    {
        y = n / c * d;
    }
    else
    {
        y = (n / c + 1) * d;
    }

    if (x > y)
    {
        cout << y << endl;
    }
    else
    {
        cout << x << endl;
    }
    return 0;
}

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

int main(void){
  int A,B,C,D,N;
  cin>>N>>A>>B>>C>>D;
  int X,Y;
  if(N%A==0){
    X=B*(N/A);
  }
  else{
    X=B*((N/A)+1);
  }
  if(N%C==0){
    Y=D*(N/C);
  }
  else{
    Y=D*((N/C)+1);
  }
  if(X<=Y){
    cout<<X<<endl;
  }
  else{
    cout<<Y<<endl;
  }
  return 0;
}

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

int main()
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	int x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		if (x * a < n)
			x++;
		if (y * c < n)
			y++;
	}

	cout << ((x * b < y * d) ? x * b : y * d) << endl;

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n,a,b,c,d,x,y,z,o,A,B;
    cin>>n>>a>>b>>c>>d;
    z=0;
    o=0;
    x=0;
    y=0;
    while(1){
        if(n<=z){break;}
        z=a+z;
        x++;
    }
    while(1){
        if(n<=o){break;}
        o=o+c;
        y++;
    }
    A=b*x;
    B=d*y;
    if(A>=B){cout<<B<<endl;}
        else{cout<<A<<endl;}
    return 0;    
    }

C++: #include <iostream>

int main(){
    int N,A,B,C,D,e,f;
    std::cin>>N>>A>>B>>C>>D;
    e = (N/A+!!(N%A))*B;
    f = ((N/C+!!(N%C))*D);
    std::cout<<(e>=f?f:e)<<'\n';
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d,xko=0,yko=0;
	cin >> n >> a >> b >> c >> d;
	if(n%a!=0){
		xko=n/a+1;
	}else{
		xko=n/a;
	}
	if(n%c!=0){
		yko=n/c+1;
	}else{
		yko=n/c;
	}
	if(b*xko<d*yko){
		cout << b*xko << endl;
	}else{
		cout << d*yko << endl;
	}
}

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

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

    int sum_pens1 = 0;
    int sum_pens2 = 0;
    int sum_money1 = 0;
    int sum_money2 = 0;
    while(sum_pens1 < N){
        sum_pens1 += A;
        sum_money1 += B;
    }

    while(sum_pens2 < N){
        sum_pens2 += C;
        sum_money2 += D;
    }

    cout << min(sum_money1, sum_money2) << endl;
}

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);
else{printf(D*y);}



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