Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.

The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.

As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible.

Input

The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners.

Output

In the first line, print a single integer — the minimum number of problems the jury needs to prepare.

Sample Input

Input
1 10
7 2
1
Output
2
Input
2 2
2 1
2
Output
0

Source

题意:有两种方案,判断一下选哪一种就行了。
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int a[];
main()
{
int c,d,n,m,k;
cin>>c>>d>>n>>m>>k;
int tem=n*m-k;
if(tem<=){cout<<<<endl;}
else
{
if((double)c/(double)n<(double)d)
{
int t=tem/n,sheng=tem-t*n,hh=sheng*d;
if(hh<c) cout<<c*t+hh<<endl;
else cout<<c*t+c<<endl;
}else
cout<<tem*d<<endl;
}
return ;
}

CodeForces - 417A(思维题)的更多相关文章

  1. Codeforces 424A (思维题)

    Squats Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Statu ...

  2. Vova and Trophies CodeForces - 1082B(思维题)

    Vova has won nn trophies in different competitions. Each trophy is either golden or silver. The trop ...

  3. CodeForces - 417B (思维题)

    Crash Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status ...

  4. B - Sonya and Exhibition CodeForces - 1004B (思维题)

    B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input stand ...

  5. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  6. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  7. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

  9. CodeForces - 1102A(思维题)

    https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...

随机推荐

  1. 【poj2226】 Muddy Fields

    http://poj.org/problem?id=2226 (题目链接) 题意 给出一个只包含‘.’和‘*’的矩阵,用任意长度的宽为1的木板覆盖所有的‘*’而不覆盖‘.’,木板必须跟矩形的长或宽平行 ...

  2. [NOIP2009] 提高组 洛谷P1071 潜伏者

    题目描述 R 国和 S 国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动.历尽艰险后,潜伏于 S 国的 R 国间谍小 C 终于摸清了 S 国军用密码的编码规则: 1. S 国军方内部欲发送的原 ...

  3. 位图索引:原理(BitMap index)

    http://www.cnblogs.com/LBSer/p/3322630.html 位图(BitMap)索引 前段时间听同事分享,偶尔讲起Oracle数据库的位图索引,顿时大感兴趣.说来惭愧,在这 ...

  4. angular2怎么使用第三方的库(jquery等)

    网上找了很多教材都搜索不到该部分类型,自己测试了下写了该教程. 场景说明:项目需要使用bootstrap,众所周知bootstrap没有时间日期控件的,需要使用第三方控件,我对如何在angular2中 ...

  5. word双面打印的方法

    首先要明白打印的过程 先进入打印机的纸张顶部,肯定是先打印,这样就确定了纸张放置的方向,不会放倒了 肯定是打印在纸张的向上的那一面,这样就确定了打印的正反面 纸张打印的顺序肯定是从上到下,这样就确定了 ...

  6. HTML5中的Range对象的研究

    一:Range对象的概念 Range对象代表页面上的一段连续区域,通过Range对象,可以获取或修改页面上的任何区域,可以通过如下创建一个空的Range对象,如下: var  range = docu ...

  7. app内嵌web的一些问题记录

    问题(1)webview里面出现大图预览,点击手机上的返回,应该是图片预览消失 问题(2)键盘输入的时候,键盘会把输入框遮挡 ------------------------------------- ...

  8. NPOI在.net中的操作Excel

    1.读取 using (FileStream stream = new FileStream(@"c:\客户资料.xls", FileMode.Open, FileAccess.R ...

  9. 百度地图代码API

    百度地图代码API: http://api.map.baidu.com/lbsapi/creatmap/index.html

  10. Brackets(区间dp)

    Brackets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3624   Accepted: 1879 Descript ...