跳过正文
  1. Posts/

(BC 一周年)hdu 5310 Souvenir

·1 分钟

http://acm.hdu.edu.cn/showproblem.php?pid=5310 水。 不要用cin.

 1
 2    /*************************************************************************
 3    	> File Name: code/bc/#ann/1001.cpp
 4    	> Author: 111qqz
 5    	> Email: rkz2013@126.com
 6    	> Created Time: 2015年07月25日 星期六 18时54分24秒
 7     ************************************************************************/
 8
 9    #include<iostream>
10    #include<iomanip>
11    #include<cstdio>
12    #include<algorithm>
13    #include<cmath>
14    #include<cstring>
15    #include<string>
16    #include<map>
17    #include<set>
18    #include<queue>
19    #include<vector>
20    #include<stack>
21    #define y0 abc111qqz
22    #define y1 hust111qqz
23    #define yn hez111qqz
24    #define j1 cute111qqz
25    #define tm crazy111qqz
26    #define lr dying111qqz
27    using namespace std;
28    #define REP(i, n) for (int i=0;i<int(n);++i)
29    typedef long long LL;
30    typedef unsigned long long ULL;
31    int n,m,p,q;
32    int main()
33    {
34        int T;
35        cin>>T;
36        int ans = 0;
37        while (T--)
38        {
39    	//  scanf("%d %d %d %d",&n,&m,&p,&q);
40    	  scanf("%d %d %d %d",&n,&m,&p,&q);
41    	  ans = n*p;
42    	  ans = min(ans,n/m*q+n%m*p);
43    	  ans = min(ans,((n-1)/m+1)*q);
44    	  printf("%d\n",ans);
45        }
46
47    	return 0;
48    }

相关文章

cf 556C Case of Matryoshkas

·1 分钟
http://codeforces.com/contest/556/problem/C 果然一晚上不睡觉会导致读错题么… 需要注意的是 如果有一个是 1 2 4 6 那么 1,2是不必拆开的….

最大连续区间和的算法总结

·2 分钟
最大连续区间和是一个经典的问题。给定一个长度为 n 的序列 a[1],a[2]…a[n-1],a[n],求一个连续的子序列 a[i],a[i+1]…a[j-1],a[j],使得 a[i]+a[i+1]…a[j-1]+a[j]最大。

cf 535B Tavas and SaDDas

·1 分钟
B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn’t stop doing that. That’s why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas’ headphones and told him: “If you solve the following problem, I’ll return it to you.”