CodeForces 469A. I Wanna Be the Guy(数学)

题目链接: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

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;
}
时间: 2024-08-24 07:57:50

CodeForces 469A. I Wanna Be the Guy(数学)的相关文章

codeforces 446C DZY Loves Fibonacci Numbers(数学 or 数论+线段树)

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2). DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of n integers: a1, a2, ...,

CodeForces 577C Vasya and Petya&#39;s Game 数学

题意就是给你一个1到n的范围 你每次可以问这个数是否可以被某一个数整除 问你要猜多少数才能确定这个数…… 一开始一点思路也没有 后来查了一下才知道 每个数都可以分为几个质数的整数次幂相乘得到…… 1 #include<stdio.h> 2 #include<iostream> 3 #include<algorithm> 4 #include<math.h> 5 #include<string.h> 6 #include<string>

CodeForces 55D Beautiful numbers(数位dp+数学)

题目链接:http://codeforces.com/problemset/problem/55/D 题意:一个美丽数就是可以被它的每一位的数字整除的数. 给定一个区间,求美丽数的个数. 显然这是一道数位dp,就是满足一个数能被所有位数的lcm整除即可. 一般都会设dp[len][mod][LCM],mod表示余数,LCM表示前len位的lcm. 但是如果直接裸mod会很复杂,于是再想lcm{0,1,2,3,4,5,6,7,8,9}=2520; 而且lcm{a,b,c,d....}{a,b,c,

codeforces 264 B. Good Sequences(dp+数学的一点思想)

题目链接:http://codeforces.com/problemset/problem/264/B 题意:给出一个严格递增的一串数字,求最长的相邻两个数的gcd不为1的序列长度 其实这题可以考虑一下素因数,将每一个数都已是分解为几个不重复的素数,设dp[i]为含有因数i的最长序列有多长 然后遍历一下这串数字,每次更新dp[a[i]]=max(dp[j]+1,dp[a[i]]),j表示a[i]的素因数,再将每个素因数更新为 最大值. for(int i = 1 ; i <= n ; i++)

CodeForces - 586C Gennady the Dentist 模拟(数学建模的感觉)

http://codeforces.com/problemset/problem/586/C 题意:1~n个孩子排成一排看病.有这么一个模型:孩子听到前面的哭声自信心就会减弱:第i个孩子看病时会发出v[i]的叫声,他后面的那个人的自信心(不是p[i+1])会减少v[i],再后面一个会减少v[i]-1,如此下去直到声音减弱为0.若某个人的自信心小于0,则他哭着跑回家,他身后的所有人会减掉d[i] 的自信. 题解:直接模拟很困难,有一个想法是将逃跑的孩子的声音和将他吓跑的(正在接诊的)声音叠加成s,

CodeForces - 1327A Sum of Odd Integers(数学+思维)

Example input Copy 6 3 1 4 2 10 3 10 2 16 4 16 5 output Copy YES YES NO YES YES NO Note In the first test case, you can represent 3 as 3. In the second test case, the only way to represent 4 is 1+3. In the third test case, you cannot represent 10 as

CodeForces 710B Optimal Point on a Line (数学,求中位数)

题意:给定n个坐标,问你所有点离哪个近距离和最短. 析:中位数啊,很明显. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring>

Codeforces 876B:Divisiblity of Differences(数学)

B. Divisiblity of Differences You are given a multiset of n integers. You should select exactly k of them in a such way that the difference between any two of them is divisible by m, or tell that it is impossible. Numbers can be repeated in the origi

Codeforces A. Double Cola 题解

题目很奇怪,就是5个人排队喝可乐,喝完之后编程两个人,然后拍在队后面,然后继续喝可乐. 给出个数值,代表第几罐可乐,问会是第几个人喝到? http://codeforces.com/problemset/problem/82/A 一个数学问题,仔细点就好了. 要熟练的知识点: 1 要熟悉解决这种递增数列,如何减去循环部分 2 要知道如何计算,求余取答案 #include <string> #include <iostream> using namespace std; void D