A - HQ9+
Problem description
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
Hi!
Output
YES
Input
Codeforces
Output
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'这三个字符中的任意一个,程序都会有输出即为"YES",否则为没有输出即为"NO",注意字符'+'只是内部累加值并不会使程序有输出,所以这种情况不算,简单水过。
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
char str[];bool flag=false;
cin>>str;
for(int i=;str[i]!='\0';++i){
if(str[i]=='H'||str[i]=='Q'||str[i]==''){flag=true;break;}
}
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}
A - HQ9+的更多相关文章
- Codeforces 133A:HQ9+
A. HQ9+ time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Oracle学习笔记十 使用PL/SQL
PL/SQL 简介 PL/SQL 是过程语言(Procedural Language)与结构化查询语言(SQL)结合而成的编程语言,是对 SQL 的扩展,它支持多种数据类型,如大对象和集合类型,可使用 ...
- Oracle学习笔记九 数据库对象
Oracle 数据库对象又称模式对象,数据库对象是逻辑结构的集合,最基本的数据库对象是表. 其他数据库对象包括:
- 3.Java网络编程之IP
前面两篇博文我们已经简单了解了IP.端口.协议以及两种参考模型,我们现在重新从程序角度来看下这个参考模型. 如果我们从事的是Web网站开发,那么我们应该知道HTML是一种超文本标记语言 (Hyper ...
- android 性能分析案例
本章以实际案例分析在android开发中,性能方面的优化和处理.设计到知识点有弱引用,memory monitor,Allocation Tracker和leakcanary插件. 1.测试demo ...
- 关于kali2.0rolling中metasploit升级后无法启动问题的解决总结
最近在学习metasploit的使用,文中提到可以使用msfupdate命令来对metasploit的payload.exploit等进行升级,我就试了一下,没想到升级过程并不麻烦,但升级后却出现了无 ...
- Oracle PL/SQL
PL/SQL 简介 PL/SQL 是过程语言(Procedural Language)与结构化查询语言(SQL)结合而成的编程语言,是对 SQL 的扩展,它支持多种数据类型,如大对象和集合类型,可使用 ...
- OAF_开发系列19_实现OAF对话框提示dialogPage(案例)
20150716 Created By BaoXinjian
- OAF_开发系列01_实现OAF资料主从关系Master-Detail联动(案例)
2014-06-02 Created By BaoXinjian
随机推荐
- spring IOC bean间关系
1.0 继承关系 实体 package com.java.test5; import java.util.*; /** * @author nidegui * @create 2019-06-22 1 ...
- SpringMVC参数绑定、Post乱码解决方法
从客户端请求key/value数据,经过参数绑定,将key/value数据绑定到controller方法的形参上. springmvc中,接收页面提交的数据是通过方法形参来接收.而不是在control ...
- JavaFX桌面应用开发-Button(按钮)与事件
1:Button样式的操作原始代码: package application; import javafx.application.Application;import javafx.scene.Gr ...
- PAT_A1133#Splitting A Linked List
Source: PAT A1133 Splitting A Linked List (25 分) Description: Given a singly linked list, you are su ...
- python下操作mysql 之 pymsql
python下操作mysql 之 pymsql pymsql是Python中操作MySQL的模块, 下载安装: pip3 install pymysql 使用操作 1, 执行SQL #!/usr/ ...
- Git学习总结(13)——使用git.oschina作为自己的源代码在线管理库
工作有几年了,期间积累了很多的代码片段,一直想找个存放的地方,方便随时的取用.以前可能是放在自己电脑的硬盘中,但毕竟这样使用起来还是有很多不便. 下面通过码云来说明 一下设置过程.其实,码云和GitH ...
- VScode使用简介
1.1 VSCode简介 VSCode官网:https://code.visualstudio.com/ 支持语音: 速度较快,对超大文件读写速度飞快(打开10M代码不到1s,Subline原生会卡近 ...
- nyoj_524_A-B Problem_201312012035
A-B Problem 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 A+B问题早已经被大家所熟知了,是不是很无聊呢?现在大家来做一下A-B吧. ...
- Blue Jeans POJ 3080 寻找多个串的最长相同子串
Description The Genographic Project is a research partnership between IBM and The National Geographi ...
- Spring MVC-集成(Integration)-生成PDF示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_pdf.htm 说明:示例基于Spring MVC 4.1.6. 以下示例显示如何 ...