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
随机推荐
- vue自定义轻量级form表单校验
遇到了form表单提交的需求,找了vue的组件觉得不够灵活,有时间自己写了一个. 调用方法 全局引入注册: import va from 'global/js/va' va.install(Vue); ...
- [SQL Service]从一张表取值更新另一张表字段
1. update table_A set table_A_column = ab.column from table_A aa left join table_B ab on aa.xx = ab ...
- JAVA学习总结-常用数据结构
java中集合框架其实就是数据结构的实现的封装; 参考资料:任小龙教学视频 1,什么是数据结构? 数据结构是计算机存储,组织数据的方式; 数据结构是指相互之间存在一种或多种特定关系的数据元素的集合; ...
- c发邮件
/* base64编码 */ static const char* base64_enc_map = \ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno ...
- 分布式服务框架Dubbo入门案例和项目源码
本项目源代码:http://download.csdn.net/detail/fansunion/9498406 Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案, 是 ...
- 4、ceph-deploy之配置使用对象存储
从firefly(v0.80)版本开始,ceph存储显著的简化了安装和配置Ceph Object Gateway, Gateway进程嵌入到Civetweb,所以你需要安装一个web服务,或者配置Fa ...
- Package pdftex.def Error: PDF mode expected, but DVI mode detected!
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/51646781 在如下使用LaTeX编译 ...
- springboot优雅的关闭应用
使用actuator,通过发送http请求关闭 将应用注册为linux服务,通过service xxx stop关闭 具体这两种方式如何实现,这里就不说了,网上百度一堆,主要讲一下在这两种情况下web ...
- printf()参数的处理
下面程序的输出为? #include <stdio.h> int main(void) { ,b=,c=; printf(),(c = c*)); ; } 答案是110..40..60 这 ...
- Linux终止进程的工具kill/killall/pkill/xkill/skill用法区别(转)
一. 终止进程的工具kill .killall.pkill.xkill 终止一个进程或终止一个正在运行的程序,一般是通过kill .killall.pkill.xkill等进行.比如一个程序已经死掉, ...