codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

188E.md (1388B)


      1 Source: https://codeforces.com/problemset/problem/188/E
      2 
      3 E. HQ9+
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 HQ9+ is a joke programming language which has only four one-character instructions:
     22 
     23 * "H" prints "Hello, World!",
     24 * "Q" prints the whole source code of the program itself (at each call),
     25 * "9" prints the lyrics of "99 Bottles of Beer" song,
     26 * "+" increments the value stored in the internal accumulator.
     27 
     28 Instructions "H" and "Q" are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.
     29 
     30 You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.
     31 
     32 Input
     33 
     34 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.
     35 
     36 Output
     37 
     38 Output "YES", if executing the program will produce any output, and "NO" otherwise (quotes for clarity only).
     39 
     40 Examples
     41 
     42 Input
     43 
     44 ```
     45 Hello!
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 YES
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 Progopedia
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 NO
     64 ```
     65 
     66 Note
     67 
     68 In the first case the program contains only one instruction — "H", which prints "Hello, World!".
     69 
     70 In the second case none of the program characters are language instructions.