Codeforces 133A:HQ9+
2 seconds
256 megabytes
standard input
standard output
HQ9+ is a joke programming language which has only four one-character instructions:
- "H" prints "Hello, World!",
- "Q" prints the source code of the program itself,
- "9" prints the lyrics of "99 Bottles of Beer" song,
- "+" increments the value stored in the internal accumulator.
Instructions "H" and "Q" are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.
You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.
The input will consist of a single line p which will give a program in HQ9+. String p will contain between 1 and 100 characters, inclusive. ASCII-code of each character of p will be between 33 (exclamation mark) and 126 (tilde), inclusive.
Output "YES", if executing the program will produce any output, and "NO" otherwise.
Hi!
YES
Codeforces
NO
In the first case the program contains only one instruction — "H", which prints "Hello, World!".
In the second case none of the program characters are language instructions.
题意:输入字符串,判断里面是否有“H”“Q”“9”“+”这四个字符(区分大小写),输入“H”“Q”“9”均有输出,但是输入“+”,只进行累加操作,没有输出。如果输入的字符串有输出,则输出“YES”(“+”是NO!!!!)
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
const double E=exp(1);
const int maxn=1e6+10;
using namespace std;
char ch[maxn];
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
cin>>ch;
int l=strlen(ch);
int flag=0;
for(int i=0;i<l;i++)
{
if(ch[i]=='H'||ch[i]=='Q'||ch[i]=='9')
flag++;
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}
Codeforces 133A:HQ9+的更多相关文章
- Codeforces 731C:Socks(并查集)
http://codeforces.com/problemset/problem/731/C 题意:有n只袜子,m天,k个颜色,每个袜子有一个颜色,再给出m天,每天有两只袜子,每只袜子可能不同颜色,问 ...
- Codeforces 747D:Winter Is Coming(贪心)
http://codeforces.com/problemset/problem/747/D 题意:有n天,k次使用冬天轮胎的机会,无限次使用夏天轮胎的机会,如果t<=0必须使用冬轮,其他随意. ...
- Codeforces 747C:Servers(模拟)
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...
- Codeforces 749D:Leaving Auction(set+二分)
http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去 ...
- Codeforces 749B:Parallelogram is Back(计算几何)
http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ...
- Codeforces 749C:Voting(暴力模拟)
http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人K ...
- Codeforces 746D:Green and Black Tea(乱搞)
http://codeforces.com/contest/746/problem/D 题意:有n杯茶,a杯绿茶,b杯红茶,问怎么摆放才可以让不超过k杯茶连续摆放,如果不能就输出NO. 思路:首先,设 ...
- Codeforces 745C:Hongcow Builds A Nation(并查集)
http://codeforces.com/problemset/problem/744/A 题意:在一个图里面有n个点m条边,还有k个点是受限制的,即不能从一个受限制的点走到另外一个受限制的点(有路 ...
- Codeforces 743D:Chloe and pleasant prizes(树形DP)
http://codeforces.com/problemset/problem/743/D 题意:求最大两个的不相交子树的点权和,如果没有两个不相交子树,那么输出Impossible. 思路:之前好 ...
随机推荐
- 2017ACM/ICPC Guangxi Invitational Solution
A: A Math Problem 题意:给出一个n,找出有多少个k满足kk <= n 思路: kk的增长很快,当k == 16 的时候就已经超过1e18 了,对于每一次询问,暴力一下就可以 ...
- git使用多个SSH公钥信息
常常在开发环境存在多个git库,比如官方的github.公司搭建的gitlab.自己的私人库等等多个git库,为了方便使用,git需要配置多个SSH公钥信息. 在centos7.5下,进入用户目录,以 ...
- PhpStorm提高效率的使用方法及设置(快捷键)
原文链接:https://my.oschina.net/chunto/blog/262954 快捷键: CTRL + D 复制当前行到下一行 或 复制选中内容到选中内容之后 CTRL + Y 删除 ...
- 20145319 《网络渗透》MS12_020安全漏洞
20145319 <网络渗透>MS12_020安全漏洞 一 实验内容 初步掌握平台matesploit辅助模块aux的使用 辅助模块包括扫描等众多辅助功能 本次展示DOS攻击的实现 有了初 ...
- 从头到尾测地理解KMP算法【转】
本文转载自:http://blog.csdn.net/v_july_v/article/details/7041827 1. 引言 本KMP原文最初写于2年多前的2011年12月,因当时初次接触KMP ...
- sqlite中的时间
插入时间的sql语句 ','-61') 时间格式'2014-11-17T19:37:32' 年月日和时分秒之间多了一个字母T,保存到数据库的时候,会自动给时间加8个小时. 保存的结果为2014-11- ...
- install ros-indigo-map-server
sudo apt-get install ros-indigo-map-server
- 使用 Git Hook 自动部署 Hexo 到个人 VPS
安装 Hexo 既然我的标题都已经那样写了,当然这个小节就不是本篇文章的重点了. 关于 Hexo 的安装跟配置,其实网上已经有很多很多文章了,随便一搜一大把.这里就有一篇超详细的,大家可以参考一下. ...
- Java Minor GC和FullGC
Minor GC触发条件:当Eden区满时,触发Minor GC. Full GC触发条件: 调用System.gc时,系统建议执行Full GC,但是不必然执行 老年代空间不足 方法去空间不足 通过 ...
- 【整理】STL中的bitset(二进制华丽解决假五维偏序题)
------------更多Bitset的运用,请看这里http://www.cnblogs.com/hua-dong/p/8519739.html. 由于在学cdq分治,看到了这道题.先来看一道题目 ...