BC一周年练习赛
Souvenir
2
1 2 2 1
1 2 3 4
1
3
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
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[l1..r1], s[l_2..r_2]s[l2..r2], s[l_3..r_3]s[l3..r3] that:
1 \le l_1 \le r_1 < l_2 \le r_2 < l_3 \le r_3 \le n1≤l1≤r1<l2≤r2<l3≤r3≤n
The concatenation of s[l_1..r_1]s[l1..r1], s[l_2..r_2]s[l2..r2], s[l_3..r_3]s[l3..r3] is "anniversary".
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.
For each test case, output "YES" (without the quotes) if Soda can find such thress substrings, otherwise output "NO" (without the quotes).
2
annivddfdersewwefary
nniversarya
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一周年练习赛的更多相关文章
- BC一周年B
#include <cstdio> #include <iostream> #include <algorithm> #include <queue> ...
- hdu 5311 Hidden String 字符串
BC一周年的题.这道题做比赛的时候A了小数据,终于评判的时候还是挂了,看来还是不认真思考的问题啊.交的时候 都没有信心过肯定是不行的.认真思考.敲一发,有信心过才是真正的acmer.赛后认真想了想,发 ...
- BestCoder 2nd Anniversary/HDU 5718 高精度 模拟
Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...
- 数据库设计范式2——BC范式和第四范式
我在很久之前的一篇文章中介绍了数据库模型设计中的基本三范式,今天,我来说一说更高级的BC范式和第四范式. 回顾 我用大白话来回顾一下什么是三范式: 第一范式:每个表应该有唯一标识每一行的主键. 第二范 ...
- TFS 10周年生日快乐 – TFS与布莱恩大叔的故事
今天看了一下Brian Harry大叔的博客,才发现2016年3月17日,是Team Foundation Server的10岁生日. Today marks the 10th anniversary ...
- Win10 PC一周年更新正式版14393.447 32位/64位更新补丁KB3200970下载 Flash补丁Kb3202790下载
微软在今天凌晨推送了Win10 PC一周年更新正式版14393.447,本次更新补丁代号为KB3200970,面向Win10一周年更新正式版的PC用户. 更新日志 • 提升了多媒体音频.远程桌面以及I ...
- Windows 10一周年更新正式版官方ISO镜像(1607)
微软已经开始推送Win10一周年更新正式版系统,按照此前预告微软官方网站也同步推出了Win10一周年更新正式版ISO官方镜像下载,版本已经升级到最新的1607,也就是Win10 Build 1607, ...
- 【ESRI论坛6周年征文】ArcEngine注记(Anno/ Label/Element等)处理专题 -入门篇
原发表于ESRI中国社区,转过来.我的社区帐号:jhlong http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=122097 ----------- ...
- BC之Claris and XOR
http://acm.hdu.edu.cn/showproblem.php?pid=5661 Claris and XOR Time Limit: 2000/1000 MS (Java/Others) ...
随机推荐
- PHP解决抢购、秒杀、抢楼、抽奖等阻塞式高并发库存防控超量的思路方法
如今在电商行业里,秒杀抢购活动已经是商家常用促销手段.但是库存数量有限,而同时下单人数超过了库存量,就会导致商品超卖甚至库存变负数的问题. 又比如:抢购火车票.论坛抢楼.抽奖乃至爆红微博评论等也会引发 ...
- Linux字符集的查看及修改
一·查看字符集 字符集在系统中体现形式是一个环境变量,以CentOS6.5为例,其查看当前终端使用字符集的方式可以有以下几种方式: 第一种: [root@Testa-www tmp]# echo $L ...
- 莫比乌斯环-vtkTriangleStrip
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- 自动化运维工具Ansible详细部署 (转载)
自动化运维工具Ansible详细部署 标签:ansible 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://sofar.blog. ...
- Test Regular Expressions Online with RegExr免费的正则表达式检验网站
免费的正则表达式检验网站: http://www.regexr.com
- STM32F103之DMA
一.背景: 需要使用STM32的DAC,例程代码中用了DMA,对DMA之前没有实际操作过,也很早就想知道DMA到底是什么,因此,看了一下午手册,代码和网上的资料,便有了此篇文章,做个记录. 二.正文: ...
- Linux Socket编程
“一切皆Socket!” 话虽些许夸张,但是事实也是,现在的网络编程几乎都是用的socket. ——有感于实际编程和开源项目研究. 我们深谙信息交流的价值,那网络中进程之间如何通信,如我们每天打开浏览 ...
- 利用 PhpStorm、Idea 等 IDE 如何 运行/调试 Go 程序 ?
以自己常用的 PhpStorm 为例 第一步:下载安装 Go插件 File -> Settings -> Plugins -> 输入关键字:Go 第二步:新建 Go项目 File - ...
- mysql的DISABLE/ENABLE KEYS
有一个表 tbl1 的结构如下: CREATE TABLE `tbl1` ( `id` int(10) unsigned NOT NULL auto_increment, `name` char(20 ...
- mount -t nfs 的使用
服务安装:1. 在VMware Ubuntu中安装NFS服务: sudo apt-get install nfs-kernel-server2. 安装成功会出现配置文件/etc/exports. ls ...