hdu 5310 Souvenir(BestCoder 1st Anniversary ($))

http://acm.hdu.edu.cn/showproblem.php?pid=5310

题目大意:要买n个纪念品,可以单个买p元每个,可以成套买q元一套,每套有m个,求最少花费

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define N 110 using namespace std; int main()
{
int t, sum, n, m, p, q, a, b;
scanf("%d", &t);
while(t--)
{
sum = ;
scanf("%d%d%d%d", &n, &m, &p, &q);
a = n / m;
b = n % m;
if((n - b) * p > a * q)
sum += a * q;
else
sum += (n - b) * p;
if(b * p > q)
sum += q;
else
sum += b * p;
printf("%d\n", sum);
}
return ;
}
上一篇:SQL注入


下一篇:告别里程焦虑 菲斯塔纯电动冬季用车指南