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<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d,cnt=0,cnt2=0,pen1=0,pen2=0,cost=0;
	cin>>n>>a>>b>>c>>d;
	while(n>=pen1){
		pen1=pen1+a;
		cnt++;}
	while(n>pen2){
		pen2=pen2+c;
		cnt2++;}
	if(cnt2*d>cnt*b)
		cost=cnt*b;
	if(cnt*b>cnt2*d)
		cost=cnt2*d;
	if(cnt2*d==cnt*b)
		cost=cnt*b;
	cout<<cost<<endl;
	
	return 0;
}

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

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

#define INF = 10000000;

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

  return 0;
}

C++: #include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=998244353;
const int mod=998244353;
int main(){
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    cout<<min((n-1)/a*b+b,(n-1)/c*d+d)<<endl;
}

C++: #include <iostream>
 
using namespace std;
 
int N,A,B,C,D
int X_SET,Y_SET,X_SUM,Y_SUM;
int main(){
cin>>N>>A>>B>>C>>D;
X_SET = N/A;
if(N%A>0)X_SET=X_SET+1;
Y_SET=N/C;
if(N%C>0)Y_SET+1;
X_SUM=B*X_SET;
Y_SUM=D*Y_SET;
if(X_SUM<Y_SUM)cout<<X_SUM<<endl;
else
cout<<Y_SUM<<endl;
return0;
}

C++: #include <iostream>
int main() {
	int N, A, B, C, D, x,y;
	std::cin >> N >> A >> B >> C >> D;
	if (N%A >= 1) {
		x = N / A + 1;
	}
	else {
		x = N / A;
	}
	if (N%C >= 1) {
		y = N/ C+ 1;
	}
	else {
		y = N / C;
	}
	
	if (x*B < y*D) {
		std::cout << x * B << std::endl;
	}
	if (x*B >= y*D) {
		std::cout << y * D << std::endl;
	}
}

C++: #include <iostream>
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<<endl;
	}else{
		cout<<r<<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;
}