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. RIP、OSPF、BGP、动态路由选路协议、自治域AS

    相关学习资料 tcp-ip详解卷1:协议.pdf http://www.rfc-editor.org/rfc/rfc1058.txt http://www.rfc-editor.org/rfc/rfc ...

  2. windows进程/线程创建过程 --- windows操作系统学习

    有了之前的对进程和线程对象的学习的铺垫后,我们现在可以开始学习windows下的进程创建过程了,我将尝试着从源代码的层次来分析在windows下创建一个进程都要涉及到哪些步骤,都要涉及到哪些数据结构. ...

  3. The prefix "mvc" for element "mvc:annotation-driven" is not bound 的解决方法

    添加 xmlns:mvc="http://www.springframework.org/schema/mvc" http://www.springframework.org/sc ...

  4. iOS开发的那些坑

    最近重新拿起了iOS的开发,使用OC和Swift混编,碰到了一些比较棘手的问题,在这里记录下来,方便自己以后或他人不再入坑.这篇文章的内容包含: UITableViewCell的真实结构在iOS的环境 ...

  5. ios 关键字 IB_DESIGNABLE IBInspectable 尝鲜

    每次都用代码定义一个属性,然后在viewDidLoad中再去设置这个属性,最常见的就是什么圆角,描边的, 现在终于可以直接像系统的属性一样在界面上设定了 界面上修改你的属性,减少代码压力

  6. zencart资源

    http://www.zen-cart.cn/ http://www.ezencart.com/

  7. CSS 仿Excel表格功能

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. WPF TreeView绑定字典集合

    <TreeView Name="Tree" HorizontalAlignment="Left" Height="269" Width ...

  9. QueryHelp

    //辅助查询 Author:高兵兵 public class QueryHelp { #region IList<T> ToList<T>(string cmdText,str ...

  10. [工具]Mac平台开发几个网络抓包工具(sniffer)

    Cocoa Packet Analyzer http://www.tastycocoabytes.com/cpa/ Cocoa Packet Analyzer is a native Mac OS X ...