SDUT 3790 UMR祝你元宵节快乐!

来源:互联网 发布:如何成为网络漫画家 编辑:程序博客网 时间:2024/05/31 13:16

UMR祝你元宵节快乐!
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description

元宵节到了,cyk 表示对 UMR 不服,于是他们进行了一场游戏:

1.他们面前有 n 个数,玩家轮流每次从这 n 个数中挑选出一个数拿走。2.玩家选取的数字大小不能超过上一次玩家所拿的数的大小(譬如,上一个玩家拿了 3,那么下一次玩家只能选择 3, 2, …)。3.当一名玩家无法挑选(没有数字了,或者剩下的数字都比上次玩家挑选的大)的时候则该玩家输掉比赛。

今天的比赛是 UMR 先手,两个人都足够聪明,然后 UMR 能不能够赢得比赛呢?

Input

输入数据有多组(数据组数不超过 55),到 EOF 结束。

第一行输入一个整数数 n (1 <= n <= 1000) 表示游戏开始时可以挑选的数的总个数。

第二行 n 个以空格分隔的整数,每个数的范围属于 [1, 1000]。

Output

对于每组数据:

如果 UMR 赢了,输出 "a ha ! cyk , too young too simple sometimes native !"。如果 cyk 赢了, 输出 "en heng UMR , you also have today !"。

输出均不包括引号。

Example Input

4
2 3 3 3
5
1 2 3 4 5
2
1 1

Example Output

a ha ! cyk , too young too simple sometimes native !
a ha ! cyk , too young too simple sometimes native !
en heng UMR , you also have today !

代码:从最小的开始只要相同的元素,不是偶数,UMR就赢

#include<stdio.h>#include<stdlib.h>int cmp(const void *a, const void *b){    return *(int *)a - *(int *)b;}int main(){    int a[1005], n, i;    int t, num, flag;    while(~scanf("%d", &n))    {        for(i = 0; i < n; i++)        scanf("%d", &a[i]);        qsort(a, n, sizeof(a[0]), cmp);//对其从小到大排序        t = a[0];        num = 1;        flag = 0;        for(i = 1; i < n; i++)        {            if(a[i] == t)            {                num++;//记录同一个元素,出现的次数            }            else            {                if(num % 2 != 0)//如果不等于0,就代表不是偶数,UMR赢                {                    flag = 1;                    break;                }                else                {                    t = a[i];//更新t元素                    num = 1;//t元素出现的次数                }            }        }        if(num % 2 != 0) flag = 1;        if(flag) printf("a ha ! cyk , too young too simple sometimes native !\n");        else printf("en heng UMR , you also have today !\n");    }    return 0;}
0 0