Codeforces 133-A problem solution

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
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.

Solution :
  • [tab]
    • C++
      • #include<bits/stdc++.h>
        using namespace std;
        
        int main()
        {
            string s;
            cin>>s;
         
            for(int i=0;i<s.length();i++)
            {
                if(s[i]=='H' || s[i]=='Q' || s[i]=='9')
                {
                     cout<<"YES"<<endl;
                    return 0;
                }
            }
         
                cout<<"NO"<<endl;
         
            return 0;
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: Codeforces 133-A problem solution
Codeforces 133-A problem solution
DorHubs
https://dorhubs.blogspot.com/2019/07/codeforces-133-problem-solution.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/07/codeforces-133-problem-solution.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy