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++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0641


#include<iostream>
 using namespace std; //標準名前空間を使用

int main(){

    //変数を読み込む
    int N , A , B ,C ,D ;
    int Xset , Yset , Xprice , Yprice;

    // セットXで揃えた場合の必要セット数(Xset)を求める
    Xset = N / A + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Xprice = Xset * B ;


    // セットYで揃えた場合のの必要セット数(Yset)を求める
    Yset = N / C + 1 ;
    // セットXで揃えた場合の合計金額を求める
    Yprice = Yset * D ;

    //XpriceとYpriceを比較する
    if(Xprice < Yprice){
    cout << Xprice ; //XpriceがYpriceより小さい場合、Xpriceを出力
    }else{
    out << Yprice ; //そうでない場合、Ypriceを出力
    }

 return 0;

 }

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

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  int ans1 = b * (n / a), ans2 = d * (n / c);
  if(n % a != 0) ans1 += b;
  if(n % c != 0) ans2 += d;
  cout << min(ans1, ans2) << endl;
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    int now = 0, ans1 = 0, ans2 = 0;

    while(now < N)
    {
        ans1 += B;
        now += A;
    }

    now = 0;

    while(now < N)
    {
        ans2 += D;
        now += C;
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

C++: #include <iostream>
using namespace std;
int nedan(int a,int i,int price){
    int E;
    if (a%i!=0){
        E=(int)((a/i)+1)*price;
    }else{
        E=(int)(a/i)*price;
    }
    return E;
}
int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    if(nedan(N,A,B)>nedan(N,C,D)){
        cout<<nedan(N,A,B)<<endl;
    }else{
        cout<<nedan(N,C,D)<<endl;
    }
}

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

C++: #include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 1000000000;

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

  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

  int ans = min((n+a-1)/a * b, (n+c-1)/c * d);

  printf("%d\n",ans);

  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 X = (N + A - 1) / A * B;
  int Y = (N + C - 1) / C * D;

  cout << min(X, 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;
	int ans = min(ceil((double)n/a)*b,ceil((double)n/c)*d);
	cout <<ans<<endl;
	return 0;
}

C++: #include <iostream>

int min(int a, int b){
    if(a>b) return b;
    else return a;
}

int price(int n, int a, int b){
    int num = a;
    int price = b;
    while(n > num) {
        num += a;
        price += b;
    }
    return price;
}
int main()
{
    int n, a, b, c, d;
    int sum[2];
    std::cin >> n >> a >> b >> c >> d;
    sum[0] = price(n,a,b);
    sum[1] = price(n,c,d);
    std::cout << min(sum[0],sum[1]) << std::endl;
    return 0;
}

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;
  
int main(){

  int n,a,b,c,d,numa,numb,suma,sumb;
  cin>>n>>a>>b>>c>>d;
  numa=n/a; numb=n/c; suma=numa*b; sumb=numb*d;
  if(n%a!=0) suma+=b;
  if(n%c!=0) sumb+=d;
  if(suma<sumb) cout<<suma<<endl;
  else cout<<sumb<<endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main (void)
{
    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<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int main() {
	ll N, A, B, C, D;
  	cin>>N>>A>>B>>C>>D;
	cin >> N >> A >> B >> C >> D;
       ll x = N/A;
       if(N%A!=0)x++;
       ll y =N/C;
       if(N%C!=0)y++;
       cout<<min(x*B,y*D)<<endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int ans=0;
  for(int i=0;1;i++){
    for(int j=0;1;j++){
      if(j*c+i*a>=n){
	if(ans==0) ans=i*b+j*d;
	else if(ans>i*a*b+j*c*d) ans=i*b+j*d;
	break;
      }
    }
    if(i*a<=n) break;
  }
  cout<<ans<<endl;
  return 0;
}

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(pen1>pen2)
		cost=cnt2*d;
	if(pen2>pen1)
		cost=cnt*b;
	if(pen1==pen2)
		cost=cnt2*d;
	cout<<cost<<endl;
	
	return 0;
}