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;

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

    int an = 0, cn = 0;
    int tmp = n;

    while (tmp > 0) {
        an += b;
        tmp -= a;
    }

    tmp = n;

    while (tmp > 0) {
        cn += d;
        tmp -= c;
    }

    cout << (an < cn ? an : cn) << endl;

}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

int main() {
    

    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    long ans1;
    long ans2;
    if(n%a == 0){
        ans1 = n/a * b;
    }else{
        ans1 = (n/a+1) * b;
    }
    if(n%c == 0){
        ans2 = n/c*d;
    }else{
        ans2 = (n/c+1)*d;
    }
    cout << min(ans1,ans2) << endl;

}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed 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>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    
    
    int a,b,c,d,p,e,n,f,x,y,z;
    
    cin>>n>>a>>b>>c>>d;
    
    if(n%a==0){
        x=n/a;
    }
    else if(n%a>0){
        x=n/a+1;
    }
    if(n%c==0){
        y=n/c;
    }
    else if(n%c>0){
        y=n/c+1;
    }
    
    z=min(x*b,y*d);
    cout<<z<<endl;
    
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
using ll = long long;
using namespace std;

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

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

    cout << min(t, tt) << 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 + N % A) * B; // 円
    y = (N / C + N % C) * D; // 円

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

    return 0;
}

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

int main() {
int N,A,B,C,D,E,F,G,H;
cin >> N >> A >> B >> C >> D;
   E = (N/A)*B;
   F = (N/C)*D;
   if(E>0&&F>0){
   if(A>C && B>D){
        G = E+B;
       cout<< G <<endl;
  } 
 
   if(A>C && B<D){
     G = E+B;
       cout<< G <<endl;
  } 
   if(A>C && B==D){
      G = E + B;
        cout<< G << endl;
  } 
  if(A<C && B>D){
       H = F+D;
       cout<< H <<endl;
 } 
   if(A<C && B<D){
        H = F+D;
       cout<< H <<endl;
    }
  if(A<C && B==D){
       H = F+B;
       cout<< H <<endl;
  } 
  
 }
  return 0;

}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    int q=0,w=0;
    if(n%a>0){q=1;}
    if(n%c>0){w=1;}
    cout << min((b*((n/a)+q)),(d*((n/c)+w))) << endl;

    return 0;
}

C++: #include<iostream>
#include<cstdio>
int main(void)
{
	int N,A,B,C,D,a,b;
	scanf("%d %d %d %d %d",&N,&A,&B,&C,&D);
	if(N%A!=0)
	{
		a=(N/A+1)*B;
	}
	else
	{
		a=(N/A)*B;
	}
	if(N%C!=0)
	{
		b=(N/C+1)*D;
	}
	else
	{
		b=(N/C)*D;
	}
	if(a>b){a=b;}
	printf("%d\n",a);
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
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;
	}else{
		cout<<r<<endl;
	}
return 0;
}

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

int n, a, b, c, d;

int main(){
  
  cin>>n>>a>>b>>c>>d;
  
  int v1 = n/a*b;
  if(n%a) v1+=b;
  
  int v2 = n/c*d;
  if(n%c) v2+=d;

  cout<<min(v1, v2)<<endl;
  
  return 0;
}

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

	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

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

C++: //JOI2018 1 Pencils
//20181208
//F_Naru
#include<iostream>
#include<algorithm>
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;
}

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

int main(){
	int N, A, B, C, D, x, y, i = 1, ans;
	cin>>N>>A>>B>>C>>D;
	
	while(1){
		if(A * i >= N) {
			x = B * i;
			break;
		}
		i++;
	}
	i = 1;
	while(1){
		if(C * i >= N) {
			y = D * i;
			break;
		}
		i++;
	}
	if(x > y) ans = y;
	else ans = x;
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n, a, b, c, d, sa, sc;
    std::scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    sa = (n % a == 0) ? n / a : n /a + 1;
    sc = (n % c == 0) ? n / c : n /c + 1;
    (sa * b <= sc * d) ? printf("%d\n", sa * b) : printf("%d\n", sc * d);
    return 0;
}

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

int N,A,B,C,D,F,Z,L,P;

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

int x;
int y;

if( N % A == 0)
F= N / A ; //FはXの個数
else
F= N / A + 1 ; 

if( N % C == 0)
L= N / C ; //LはYの個数
else
L= N / C + 1; //LはYの個数

Z=B*F; //ZはXで揃えた場合の合計金額
P=L*D; //PはYで揃えた場合の合計金額
 //set x   F=N/A+1 Z=B*F
 //set y   L=N/C+1 P=L*D

 if (Z<P)
cout<<Z<<endl;
 else
cout<<P<<endl;

return 0;
}

C++: //18-1 鉛筆
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    double N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    cout << min(ceil(N/A)*B,ceil(N/C)*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;
}