Souvenir

 Accepts: 901
 Submissions: 2743
 Time Limit: 2000/1000 MS (Java/Others)
 Memory Limit: 262144/262144 K (Java/Others)
Problem Description
Today is the 1st anniversary of BestCoder. Soda, the contest manager, wants to buy a souvenir for each contestant. You can buy the souvenir one by one or set by set in the shop. The price for a souvenir is $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.
Input
There are multiple test cases. The first line of input contains an integer $T$ $(1 \le T \le 10^5)$, indicating the number of test cases. For each test case: There's a line containing 4 integers $n, m, p, q$ $(1 \le n, m, p, q \le 10^4)$.
Output
For each test case, output the minimum cost needed.
Sample Input
2
1 2 2 1
1 2 3 4
Sample Output
1
3
Hint

For 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 <cstring>
#include <algorithm>
#include <cstdio>
using namespace std; int main()
{
int T;
cin >> T;
int n, m, p, q;
int ans;
while(T--) {
ans = ;
cin >> n >> m >> p >> q;
int zu = n / m;
int yu = n % m;
if(zu == ) {
ans = min(yu*p, q);
} else {
if(yu == ) {
ans = min(zu * q, n * p);
} else {
ans = min(zu * q + yu * p, min((zu + )* q , n * p));
}
}
cout << ans << endl;
}
return ;
}

Hidden String

 Accepts: 437
 Submissions: 2174
 Time Limit: 2000/1000 MS (Java/Others)
 Memory Limit: 262144/262144 K (Java/Others)
Problem Description

Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a string ss of length nn. He wants to find three nonoverlapping substrings s[l_1..r_1]s[l​1​​..r​1​​], s[l_2..r_2]s[l​2​​..r​2​​], s[l_3..r_3]s[l​3​​..r​3​​] that:

  1. 1 \le l_1 \le r_1 < l_2 \le r_2 < l_3 \le r_3 \le n1≤l​1​​≤r​1​​<l​2​​≤r​2​​<l​3​​≤r​3​​≤n

  2. The concatenation of s[l_1..r_1]s[l​1​​..r​1​​], s[l_2..r_2]s[l​2​​..r​2​​], s[l_3..r_3]s[l​3​​..r​3​​] is "anniversary".

Input

There are multiple test cases. The first line of input contains an integer TT (1 \le T \le 100)(1≤T≤100), indicating the number of test cases. For each test case:

There's a line containing a string ss (1 \le |s| \le 100)(1≤∣s∣≤100) consisting of lowercase English letters.

Output

For each test case, output "YES" (without the quotes) if Soda can find such thress substrings, otherwise output "NO" (without the quotes).

Sample Input
2
annivddfdersewwefary
nniversarya
Sample Output
YES
NO
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
char str[];
char const s[] = "anniversary";
int vis[];
int len, h;
bool dfs(int a, int b) {
h++;
int i, j, k;
for(i = a; i < len; ++i) {
k = b;
if(str[i] == s[k]) {
k++;
for(j = i+; j < len; ++j) {
if(str[j] != s[k])
break;
k++;
}
if(s[k] == '\0' && h<=)
return true;
if(dfs(j, k)) {
return true;
}
}
}
h--;
return false;
} int main() {
int T;
scanf("%d%*c", &T);
while(T--) {
gets(str);
len = strlen(str);
h = ;
if(dfs(, ))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return ;
}

BC一周年练习赛的更多相关文章

  1. BC一周年B

    #include <cstdio> #include <iostream> #include <algorithm> #include <queue> ...

  2. hdu 5311 Hidden String 字符串

    BC一周年的题.这道题做比赛的时候A了小数据,终于评判的时候还是挂了,看来还是不认真思考的问题啊.交的时候 都没有信心过肯定是不行的.认真思考.敲一发,有信心过才是真正的acmer.赛后认真想了想,发 ...

  3. BestCoder 2nd Anniversary/HDU 5718 高精度 模拟

    Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...

  4. 数据库设计范式2——BC范式和第四范式

    我在很久之前的一篇文章中介绍了数据库模型设计中的基本三范式,今天,我来说一说更高级的BC范式和第四范式. 回顾 我用大白话来回顾一下什么是三范式: 第一范式:每个表应该有唯一标识每一行的主键. 第二范 ...

  5. TFS 10周年生日快乐 – TFS与布莱恩大叔的故事

    今天看了一下Brian Harry大叔的博客,才发现2016年3月17日,是Team Foundation Server的10岁生日. Today marks the 10th anniversary ...

  6. Win10 PC一周年更新正式版14393.447 32位/64位更新补丁KB3200970下载 Flash补丁Kb3202790下载

    微软在今天凌晨推送了Win10 PC一周年更新正式版14393.447,本次更新补丁代号为KB3200970,面向Win10一周年更新正式版的PC用户. 更新日志 • 提升了多媒体音频.远程桌面以及I ...

  7. Windows 10一周年更新正式版官方ISO镜像(1607)

    微软已经开始推送Win10一周年更新正式版系统,按照此前预告微软官方网站也同步推出了Win10一周年更新正式版ISO官方镜像下载,版本已经升级到最新的1607,也就是Win10 Build 1607, ...

  8. 【ESRI论坛6周年征文】ArcEngine注记(Anno/ Label/Element等)处理专题 -入门篇

    原发表于ESRI中国社区,转过来.我的社区帐号:jhlong http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=122097 ----------- ...

  9. BC之Claris and XOR

    http://acm.hdu.edu.cn/showproblem.php?pid=5661 Claris and XOR Time Limit: 2000/1000 MS (Java/Others) ...

随机推荐

  1. Node.js入门笔记(6):web开发方法

    使用node进行web开发 用户上网流程: 表面上看:打开浏览器--输入网址--跳转--上网. 背后的过程是什么呢? http请求网址到指定的主机--服务器接收请求--服务器响应内容到用户浏览器--浏 ...

  2. centos6.5升级python为2.7

    今天线上服务器全部升级python环境为python-2.7.6的环境,我采用的方法是ansible+shell,代码如下,友提,Python-2.7.6.tgz.setuptools-14.3.1. ...

  3. winform 多线程编程

    参考资料: WinForm中新开一个线程操作 窗体上的控件(跨线程操作控件) c# 使用定时器Timer

  4. Excel—身份证生日提取

    一.只有18位的身份证号码 如: 身份证号 330682199302264000 41120019890823729X 231081199002256839 131101198203154666 36 ...

  5. Go - 变量初始化 及 注意事项

    Go变量 初始化 对 复合类型(数组.切片.字典.结构体)变量的初始化是,有一些语法限制: 1.初始化表达式必须包含类型标签: 2.左花括号必须在类型尾部,不能另起一行: 3.多个成员初始值以逗号分隔 ...

  6. touch移动触屏滑动事件

    移动端触屏滑动的效果其实就是图片轮播,在PC的页面上很好实现,绑定click和mouseover等事件来完成.但是在移动设备上,要实现这种轮播的效果,就需要用到核心的touch事件.处理touch事件 ...

  7. DPM算法源程序voc-release5在Windows中的配置修改过程

    最近的<视频处理与分析>课程中有一个大作业,是有关DPM物体检测算法的.网上有DPM的源代码,但是原版只能在Linux或Mac上运行,而我的电脑是Windows系统,于是在网上搜了一下在怎 ...

  8. PHP array 操作函数

    array_map 函数的介绍 将数组的每个单元使用回调函数格式: array_map(callback, array) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

  9. python接收图片变成缩略图

    python图像处理库:Pillow初级教程 Image类 Pillow中最重要的类就是Image,该类存在于同名的模块中.可以通过以下几种方式实例化:从文件中读取图片,处理其他图片得到,或者直接创建 ...

  10. Python基础二

    1.for循环后接else __author__ = "zhou" age_of_oldboy = 56 for i in range(3): guess_age = int(in ...