HDU 5310 Souvenir
Souvenir
p
yuan and the price for a set of souvenirs if
q
yuan. There's m
souvenirs in one set.There's
n
contestants in the contest today. Soda wants to know the minimum cost needed to buy a souvenir for each contestant.
T
(1≤T≤105),
indicating the number of test cases. For each test case:There's a line containing 4 integers
n,m,p,q
(1≤n,m,p,q≤104).
2
1 2 2 1
1 2 3 4
1
3HintFor the first case, Soda can use 1 yuan to buy a set of 2 souvenirs. For the second case, Soda can use 3 yuan to buy a souvenir.#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h> using namespace std; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
__int64 sum = 0;
int n,m,p,q;
scanf("%d%d%d%d",&n,&m,&p,&q);
if(p*m<=q)
{
printf("%d\n",p*n);
}
else
{
sum = (n/m)*q;
n = n%m;
if(n*p<q)
{
printf("%I64d\n",sum+n*p);
}
else
{
printf("%I64d\n",sum+q);
}
}
}
return 0;
}
HDU 5310 Souvenir的更多相关文章
- hdu 5310 Souvenir(BestCoder 1st Anniversary ($))
http://acm.hdu.edu.cn/showproblem.php?pid=5310 题目大意:要买n个纪念品,可以单个买p元每个,可以成套买q元一套,每套有m个,求最少花费 #include ...
- hdu 5310 Souvenir (水)
题意:今天是BestCoder一周年纪念日. 比赛管理员Soda想要给每个参赛者准备一个纪念品. 商店里纪念品的单价是p元, 同时也可以花q元购买纪念品套装, 一个套装里有m个纪念品.今天总共有n个参 ...
- hdu 5310(贪心)
题意:要买n个纪念品,单价p元,有团购价 m个q元,问怎样买钱最少 这个是BC周年庆第一题,水题昂,小学数学题,就是看n个纪念品单买.总体买团购然后零头买单价的.全部买团购价的多买也无所谓的,然后直接 ...
- (01背包)Buy the souvenirs (hdu 2126)
http://acm.hdu.edu.cn/showproblem.php?pid=2126 Buy the souvenirs Time Limit: 10000/1000 MS (Java/Oth ...
- hdu 2126 Buy the souvenirs 二维01背包方案总数
Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU 2126 01背包(求方案数)
Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 2126 Buy the souvenirs(记录总方案数的01背包)
Buy the souvenirs Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
随机推荐
- C#-基础部分思维导图
C#-基础部分思维导图 链接:http://pan.baidu.com/s/1jHNgS78 密码:3i74 如果有错我,请告诉我,传播错误的知识是违法的.
- 阅读《Android 从入门到精通》(15)——数字时钟
数字时钟(DigitalClock) java.lang.Object; android.view.View; android.widget.TextView; android.widget.Digi ...
- 阿里云server部署架构
近期要上马一个项目,客户要求所有部署到阿里云的server,做了一个阿里云的部署方案. 上图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc21hbGx ...
- 怎样获取ios设备的唯一标识
非常多地方都会须要用到唯一标志. 比方: 1. 我们相用一个设备的唯一标志当作用户id,特别是网络游戏,这样就能够省去注冊的麻烦. 2. 想把app相关的文件加密,密钥哪里来的?有些人可能会说hard ...
- spring RestTemplate 实例(NameValuePair)
第一种: public List<NameValuePair> getThirdsysPermissionRest(String url,ThirdsysFuncpDTO thirdsys ...
- C++ Primer Plus的若干收获--(九)
这篇博文我接着上一篇来写,相同讲一些关于类的一些基础知识. 本篇将会继续使用上篇的股票类STock,这里给出接口 ifndef STOCKOO_H_ #define STOCKOO_H_ #inclu ...
- JavaScript 没有函数重载&Arguments对象
对于学过Java的人来说.函数重载并非一个陌生的概念,可是javaScript中有函数重载么...接下来我们就进行測试 <script type="text/javascript&qu ...
- Scala语言
一.Scala概述 Scala简介 Scala是一种针对JVM将函数和面向对象技术组合在一起的编程语言.所以Scala必须要有JVM才能运行,和Python一样,Scala也是可以面向对象和面向函数的 ...
- JSP中动态include与静态include的区别介绍
转自:https://m.jb51.net/article/43304.htm 动态INCLUDE 用法:<jsp:include page="included.jsp" f ...
- 26.boost文件库
#define _CRT_SECURE_NO_WARNINGS #include <boost/filesystem/operations.hpp> #include <boost/ ...