• (BC 一周年)hdu 5310 Souvenir


    Souvenir

     
     Accepts: 901
     
     Submissions: 2743
     Time Limit: 2000/1000 MS (Java/Others)
     
     Memory Limit: 262144/262144 K (Java/Others)
    问题描述
    今天是BestCoder一周年纪念日. 比赛管理员Soda想要给每个参赛者准备一个纪念品. 商店里纪念品的单价是$p$元, 同时也可以花$q$元购买纪念品套装, 一个套装里有$m$个纪念品.
    
    今天总共有$n$个参赛者, Soda想要知道最少需要花多少钱才可以给每个人都准备一个纪念品.
    输入描述
    输入有多组数据. 第一行有一个整数$T$ $(1 le T le 10^5)$, 表示测试数据组数. 然后对于每组数据:
    
    一行包含4个整数 $n, m, p, q$ $(1 le n, m, p, q le 10^4)$.
    输出描述
    对于每组数据输出最小花费.
    输入样例
    2
    1 2 2 1
    1 2 3 4
    输出样例
    1
    3
    Hint
    对于第一组数据, Soda可以1元购买一个套装. 对于第二组数据, Soda可以直接花3元购买一个纪念品.


    水.
    只说三句话.
    不要用cin!
    不要用cin!
    不要用cin!
    /*************************************************************************
        > File Name: code/bc/#ann/1001.cpp
        > Author: 111qqz
        > Email: rkz2013@126.com 
        > Created Time: 2015年07月25日 星期六 18时54分24秒
     ************************************************************************/
    
    #include<iostream>
    #include<iomanip>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    #include<cstring>
    #include<string>
    #include<map>
    #include<set>
    #include<queue>
    #include<vector>
    #include<stack>
    #define y0 abc111qqz
    #define y1 hust111qqz
    #define yn hez111qqz
    #define j1 cute111qqz
    #define tm crazy111qqz
    #define lr dying111qqz
    using namespace std;
    #define REP(i, n) for (int i=0;i<int(n);++i)  
    typedef long long LL;
    typedef unsigned long long ULL;
    int n,m,p,q;
    int main()
    {
        int T;
        cin>>T;
        int ans = 0;
        while (T--)
        {
        //  scanf("%d %d %d %d",&n,&m,&p,&q);
          scanf("%d %d %d %d",&n,&m,&p,&q);
          ans = n*p;
          ans = min(ans,n/m*q+n%m*p);
          ans = min(ans,((n-1)/m+1)*q);
          printf("%d
    ",ans);
        }
      
        return 0;
    }
  • 相关阅读:
    2021年2月13
    2021年2月12
    2021年2月11
    2021年2月10
    2021年2月9
    下载优化
    20180301越努力越轻松
    2018-03-01继续完善2
    2018-03-01继续完善
    2018-02-16 GetSameTypeQuestion
  • 原文地址:https://www.cnblogs.com/111qqz/p/4684218.html
Copyright © 2020-2023  润新知