A. HQ9+
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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

Output "YES", if executing the program will produce any output, and "NO" otherwise.

Examples
input
Copy
Hi!
output
Copy
YES
input
Copy
Codeforces
output
Copy
NO
Note

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+的更多相关文章

  1. Codeforces 731C:Socks(并查集)

    http://codeforces.com/problemset/problem/731/C 题意:有n只袜子,m天,k个颜色,每个袜子有一个颜色,再给出m天,每天有两只袜子,每只袜子可能不同颜色,问 ...

  2. Codeforces 747D:Winter Is Coming(贪心)

    http://codeforces.com/problemset/problem/747/D 题意:有n天,k次使用冬天轮胎的机会,无限次使用夏天轮胎的机会,如果t<=0必须使用冬轮,其他随意. ...

  3. Codeforces 747C:Servers(模拟)

    http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...

  4. Codeforces 749D:Leaving Auction(set+二分)

    http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去 ...

  5. Codeforces 749B:Parallelogram is Back(计算几何)

    http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ...

  6. Codeforces 749C:Voting(暴力模拟)

    http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人K ...

  7. Codeforces 746D:Green and Black Tea(乱搞)

    http://codeforces.com/contest/746/problem/D 题意:有n杯茶,a杯绿茶,b杯红茶,问怎么摆放才可以让不超过k杯茶连续摆放,如果不能就输出NO. 思路:首先,设 ...

  8. Codeforces 745C:Hongcow Builds A Nation(并查集)

    http://codeforces.com/problemset/problem/744/A 题意:在一个图里面有n个点m条边,还有k个点是受限制的,即不能从一个受限制的点走到另外一个受限制的点(有路 ...

  9. Codeforces 743D:Chloe and pleasant prizes(树形DP)

    http://codeforces.com/problemset/problem/743/D 题意:求最大两个的不相交子树的点权和,如果没有两个不相交子树,那么输出Impossible. 思路:之前好 ...

随机推荐

  1. Check out our list of adidas NMD Singapore retailers

    The adidas NMD Singapore is confirmed to produce on The month of january 14th at select adidas Origi ...

  2. eclipse-maven安装配置java-web-servlet

    eclipse-maven安装配置java-web-servlet 系统说明: win7 64位 一. Maven安装 环境 要求 看Maven下载说明也行 jdk7.0以上 安装配置Maven 下载 ...

  3. http之post和get请求的区别

    GET请求 GET /books/?sex=man&name=Professional HTTP/1.1 Host: www.wrox.com User-Agent: Mozilla/5.0 ...

  4. RedHot 不能联网 ifconfig命令只显示lo 不显示eth0的解决方法!

    1.修改eth0 具体步骤如下 vi /etc/sysconfig/network-scripts/ifcfg-eth0, i,进入insert编辑模式,具体参数设置如下: DEVICE=eth0 B ...

  5. python webdriver 测试框架-数据驱动xml驱动方式

    数据驱动xml驱动的方式 存数据的xml文件:TestData.xml: <?xml version="1.0" encoding="utf-8"?> ...

  6. PHP文件锁 解决并发问题

    使用多线程或是多进程时. 难免会遇到并发问题. 处理简单的并发可以使用这个办法来解决 flock($fp = fopen($lock, 'w+'), LOCK_EX | LOCK_NB)   or e ...

  7. linux下如何退出tmux和重新进入tmux

    1.退出(detach)当前tmux ctrl+d 2.重新进入tmux tmux attach -t <target-session> 如:当前有很多session,那么选择哪一个呢? ...

  8. 【Dubbo基础】dubbo学习过程、使用经验分享及实现原理简单介绍

    一.前言 部门去年年中开始各种改造,第一步是模块服务化,这边初选dubbo试用在一些非重要模块上,慢慢引入到一些稍微重要的功能上,半年时间,学习过程及线上使用遇到的些问题在此总结下. 整理这篇文章差不 ...

  9. Easy install ryu

    参考:Ubuntu14.04安装Ryu控制器 环境:Ubuntu 14.04 64bit 使用pip安装ryu: // dependencies sudo apt-get install Python ...

  10. Factory Method(工厂方法)

    Factory Method(工厂方法) 意图: 定义一个用于创建对象的接口,让子类决定实例化哪一个类.Factory Method 使一个类的实例化延迟到其子类. 适用性: 当一个类不知道它所必须创 ...