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>
using namespace std;

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

  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;
	}
    }
  else if(n % c == 0)
    {
      cout << (n/c)*d << endl;
    }
  else if(n % a == 0)
    {
      cout << (n/a)*b << endl;
    }
  else
    {
      num1= (n/a)+1;
      num2= (n/c)+1;
      if(num1*b < num2*d)
	{
	  cout << num1*b << endl;
	}
      else
	{
	  cout << num2*d << endl;
	}
    }
}

C++: #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
int n,a,b,c,d;
cin >> n >> a >> b >> c >> d;
int x=(n-1)/a+1;
int y=(n-1)/c+1;
cout << min(x*b,y*d) << endl;
}

C++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	cout << min((n % a ? n / a + 1 : n / a) * b, (n % c ? n / c + 1 : n / c) * d) << endl;
}

C++: #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  assert(0);
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int mx = 0;
  for(int i=0;i<n;i++){
    int j = i;
    while(j < n && A[j] == 1) j++;
    Max(mx,j - i);
  }

  cout<<mx+1<<endl;

  
  return 0;
}

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

int main(void){
    int n, a, b, c, d;
    int sum1 = 0, sum2 = 0;
    int kane1 = 0, kane2 = 0;

    cin >> n >> a >> b >> c >> d;
    
    while(sum1 < n){
        sum1 += a;
        kane1 += b; 
    }
    while(sum2 < n){
        sum2 += c;
        kane2 += d;
    }
    if(kane1 < kane2){
        cout << kane1 << endl;
    }else{
        cout << kane2 << endl;
    }
}

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

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

int main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	int ans_x = 0; int ans_y = 0; int n_x = n; int n_y = n;
	while (n_x > 0) { n_x = n_x - a; ans_x = ans_x + b; }
	while (n_y > 0) { n_y = n_y - c; ans_y = ans_y + d; }
	cout << (ans_x > ans_y ? ans_y : ans_x) << endl;
	return 0;
}

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

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int x,y;
  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;

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

C++: #include<iostream>
#include<stdio.h>

using namespace std;

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

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

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

C++: #include <iostream>

using namespace std;

int main()
{
	int  n, a, b, c, d, a1, a2;
	cin >> n >> a >> b >> c >> d;
	a1 = b * ((n / a) + 1);
	if (n%a == 0)
	{
		a1 -= b;
	}
	a2 = d * ((n / c) + 1);
	if (n%c == 0)
	{
		a2 -= d;
	}
	if (a1 < a2)
	{
		cout << a1 << endl;
	}
	else
		cout << a2 << 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,y;
	int valueX;
	int valueY;

	if(n%a == 0){
		x = n/a;	
	}
	else{
		x = n/a + 1;
	}

	if(n%c == 0){
		y = n/c;
	}
	else{
		y = n/c +1;
	}

	valueX = x*b;
	valueY = y*d;

	if(valueX <= valueY){
		cout << valueX << endl;
	}
	else{
		cout << valueY << 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;

  if(N%A == 0){
  min = N/A * B;
  }
  else {
    min = (N/A + 1) * B;
  }

  if(N%C == 0){
    if(min > N/C*D){
      min = N/C * D;
    }
  }
  else {
    if(min > (N/C + 1) * D){
      min = (N/C + 1) * D;
    }
  }

  
  cout << min << endl;
  return 0;
}