我是靠谱客的博主 妩媚康乃馨,这篇文章主要介绍codeforces 133A HQ9+(字符串水题),现在分享给大家,希望可以做个参考。

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.

Sample test(s)
Input
复制代码
1
Hi!
Output
复制代码
1
YES
Input
复制代码
1
Codeforces
Output
复制代码
1
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.

不多说,上代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream> #include<string.h> using namespace std; int main() { char s[101]; bool flag; int i,k; while(cin>>s) { flag=true; k=strlen(s); for(i=0;i<k;i++) { if(s[i]=='H'||s[i]=='Q'||s[i]=='9') { cout<<"YES"<<endl; flag=false; break; } } if(flag) cout<<"NO"<<endl; } return 0; }


最后

以上就是妩媚康乃馨最近收集整理的关于codeforces 133A HQ9+(字符串水题)的全部内容,更多相关codeforces内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部