首页 > 编程知识 正文

Codeforces刷题之路——133A HQ9+

时间:2023-05-03 08:03:21 阅读:249617 作者:4062

mhdyx time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

激昂的路灯 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 激昂的路灯. 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 激昂的路灯. 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.


题目大意:只要字符串中含有pcdwx,搞怪的电源,"9","+",其中任意一个字符,即输出YES,若不包含任何一个即输出NO 解题思路:水题,暴力遍历即可。 注意事项:无
以下为解题代码(java实现) import java.util.Scanner;public class Main {public static void main(Stringsfdxh args) {// TODO Auto-generated method stubScanner scanner = new Scanner(System.in);String string = scanner.nextLine();charsfdxh ch = string.toCharArray();boolean flag = false;for(int i = 0;i < ch.length;i++){if(ch[i] == 'H'){flag = true;break;}if(ch[i] == 'Q'){flag = true;break;}if(ch[i] == '9'){flag = true;break;}}if(flag){System.out.println("YES");}else{System.out.println("NO");}}}
青浦)win7中qq截图快捷键是什么

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。