codeforces 133A HQ9+(字符串水题)
2014-05-31 11:59
836 查看
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
Output
Input
Output
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.
不多说,上代码:
点击打开题目
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
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.
不多说,上代码:
#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 236A . Boy or Girl(字符串水题)
- codeforces 112APetya and Strings(字符串水题)
- codeforces 96A (字符串模拟水题)
- codeforces 716B字符串水题
- codeforces 118A String Task(字符串水题)
- codeforces 112APetya and Strings(字符串水题)
- Codeforces - 748B Santa Claus and Keyboard Check(字符串水题)
- CodeForces - 58B Coins(水题。。大水题)
- Codeforces 609C Load Balancing 【水题】
- poj 字符串相关的水题
- Codeforces--630A--Again Twenty Five! (水题)
- Diverse Permutation - CodeForces 482 A 水题
- poj3981字符串替换 水的以至于浪费时间的水题
- CodeForces 955D Scissors(字符串哈希)
- Codeforces 463B Caisa and Pylons(水题)
- CodeForces - 883F(字符串模拟)
- codeforces 669C C. Little Artem and Matrix(水题)
- codeforces 442 A. Alex and broken contest(水题)
- Codeforces 588B Duff in Love【暴力】水题
- Codeforces 651B Beautiful Paintings【贪心】水题