CodeForces 469A. I Wanna Be the Guy(数学)
2014-09-21 18:47
344 查看
题目链接:http://codeforces.com/contest/469/problem/A
A. I Wanna Be the Guy
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
There is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass
the whole game.
Little X can pass only p levels of the game. And Little Y can pass only q levels
of the game. You are given the indices of levels Little X can pass and the indices of levels Little Y can pass. Will Little X and Little Y pass the whole game, if they cooperate each other?
Input
The first line contains a single integer n (1 ≤ n ≤ 100).
The next line contains an integer p (0 ≤ p ≤ n) at
first, then follows p distinct integers a1, a2, ..., ap (1 ≤ ai ≤ n).
These integers denote the indices of levels Little X can pass. The next line contains the levels Little Y can pass in the same format. It's assumed that levels are numbered from 1 to n.
Output
If they can pass all the levels, print "I become the guy.". If it's impossible, print "Oh,
my keyboard!" (without the quotes).
Sample test(s)
input
output
input
output
Note
In the first sample, Little X can pass levels [1 2 3], and Little Y can pass level [2 4], so they can pass all the levels both.
In the second sample, no one can pass level 4.
代码如下:
A. I Wanna Be the Guy
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
There is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass
the whole game.
Little X can pass only p levels of the game. And Little Y can pass only q levels
of the game. You are given the indices of levels Little X can pass and the indices of levels Little Y can pass. Will Little X and Little Y pass the whole game, if they cooperate each other?
Input
The first line contains a single integer n (1 ≤ n ≤ 100).
The next line contains an integer p (0 ≤ p ≤ n) at
first, then follows p distinct integers a1, a2, ..., ap (1 ≤ ai ≤ n).
These integers denote the indices of levels Little X can pass. The next line contains the levels Little Y can pass in the same format. It's assumed that levels are numbered from 1 to n.
Output
If they can pass all the levels, print "I become the guy.". If it's impossible, print "Oh,
my keyboard!" (without the quotes).
Sample test(s)
input
4 3 1 2 3 2 2 4
output
I become the guy.
input
4 3 1 2 3 2 2 3
output
Oh, my keyboard!
Note
In the first sample, Little X can pass levels [1 2 3], and Little Y can pass level [2 4], so they can pass all the levels both.
In the second sample, no one can pass level 4.
代码如下:
#include <cstdio> #include <cstring> int main() { int n; int vis[1117]; while(~scanf("%d",&n)) { int x, y; memset(vis,0,sizeof(vis)); int tt; scanf("%d",&x); for(int i = 0; i < x; i++) { scanf("%d",&tt); vis[tt] = 1; } scanf("%d",&y); for(int i = 0; i < y; i++) { scanf("%d",&tt); vis[tt] = 1; } int flag = 0; for(int i = 1; i <= n; i++) { if(vis[i] == 0) { flag = 1; break; } } if(flag) { printf("Oh, my keyboard!\n"); } else printf("I become the guy.\n"); } return 0; }
相关文章推荐
- CodeForces 567C. Geometric Progression(map 数学啊)
- codeforces 153 A. Points on Line 简单数学题 简单推导推导的事情
- 【数学题】【Codeforces 164 Div2 E】【Playlist】
- 【CodeForces】115D Unambiguous Arithmetic Expression 组合数学
- codeforces 4A Watermelon(数学水题)
- Codeforces 626D Jerry's Protest 「数学组合」「数学概率」
- CodeForces - 630F Selection of Personnel (组合数学)
- 【CodeForces 534A】Exam 【数学构造】
- codeforces 630H (组合数学)
- codeforces - 257c View Angle 【数学】
- Codeforces--597A--Divisibility(数学)
- CodeForces 596 A Wilbur and Swimming Pool【数学】
- Codeforces 40E Number Table - 组合数学
- codeforces 792D——Paths in a Complete Binary Tree(二叉树,数学)
- Codeforces 1A (数学题)
- CodeForces 452B 4-point polyline (数学)
- codeforces 554C Kyoya and Colored Balls 【组合数学+费马小定理】
- CodeForces 453A(数学期望)
- CodeForces - 233B Non-square Equation (数学
- CodeForces - 707C Pythagorean Triples(数学+规律)