Kagome Kagome

来源:互联网 发布:苹果手机画图软件 编辑:程序博客网 时间:2021/02/28 10:54

Kagome Kagome
Crawling in process...Crawling failed
Time Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu


Kagome kagome, kago no naka no tori waItsu itsu deyaru? Yoake no ban niTsuru to kame to subetta.Ushiro no shoumen daare?
Kagome kagome, the bird in the cage,when will you come out?In the evening of the dawn,the crane and turtle slipped.Who stands right behind you now?

Kagome Kagome is a Japanese children's game. One child is chosen as the oni (literally demon or ogre, but similar to the concept of "it" in tag) and sits blindfolded (or with their eyes covered). The other children join hands and walk in circles around the oni while singing the song for the game. When the song stops, theoni speaks aloud the name of the person behind him, and if he is correct, the person behind will exchange places with theoni.

Higurashi Tewi is playing Kagome Kagome with her n (n is even) friends as theoni now. She peeps to know who is right in front of her. Knowing the order of the children in circle and assuming that they keep distance evenly, it's easy to derive who is right behind her.


There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases.

The first line of each test case starts with an even number 1 ≤ n ≤ 100, followed by the name of the child who is right in front of Higurashi Tewi. The second line contains exactlyn different names, listed in counterclockwise order. Name is an alphanumeric string whose length never exceeds 20. It's guaranteed that the child in front of Higurashi Tewi is always contained in the list exactly once.


For each test case, output the name of the child who is right behind Higurashi Tewi.

Sample Input

32 AliceAlice Bob4 inuinu neko usagi kizune4 catdog cat rabbit fox

Sample Output



  • http://en.wikipedia.org/wiki/Kagome_Kagome

#include<stdio.h>#include<string.h>char s[107][27];char z[27];int main(){    int m;    while(scanf("%d",&m)!=EOF)    {        while(m--)        {            int n;            scanf("%d%s",&n,z);            for(int a=0;a<n;a++)            scanf("%s",s[a]);            int count,count1,count2;            for(int b=0;b<n;b++)            if(strcmp(z,s[b])==0)            {                count=b;                break;            }            count1=n/2;            count2=count1+count;            if(count2<=(n-1))printf("%s\n",s[count2]);            else            {                int count3=count2-n;                printf("%s\n",s[count3]);            }        }    }}