ZOJ3492 Kagome Kagome
来源:互联网 发布:stata软件下载 编辑:程序博客网 时间:2024/03/28 15:51
Kagome kagome, kago no naka no tori waItsu itsu deyaru? Yoake no ban niTsuru to kame to subetta.Ushiro no shoumen daare?Translation:
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, the oni speaks aloud the name of the person behind him, and if he is correct, the person behind will exchange places with the oni.
Higurashi Tewi is playing Kagome Kagome with her n (n is even) friends as the oni 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.
Input
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 exactly ndifferent 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.
Output
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
Bobusagifox
#include<stdio.h>#include<string.h>char s[104][24];int main(){ int t,i,n,xi,ans; while(scanf("%d",&t)!=EOF) { while(t--) { scanf("%d%s",&n,s[0]); for(i=1; i<=n; i++) { scanf("%s",s[i]); if(!strcmp(s[0],s[i])) xi=i; } ans=(xi+n/2)%n; if(ans==0) ans=n; printf("%s\n",s[ans]); } } return 0;}
- ZOJ3492 Kagome Kagome
- ZOJ3492-Kagome Kagome
- Kagome Kagome
- F Kagome Kagome
- zoj 3492 Kagome Kagome
- zoj 3492 Kagome Kagome
- ZOJ 3492 Kagome Kagome
- ZOJ 3488 Kagome Kagome
- zoj 3492 Kagome Kagome
- ZOJ 3492 Kagome Kagome
- ZOJ 3492Kagome Kagome
- ZOJ-3492 Kagome Kagome
- ZOJ 3492Kagome Kagome
- ZOJ 3492 F - Kagome Kagome
- ZOJ Problem Set - 3492||Kagome Kagome
- 2014ACM集训13级PK赛2-Kagome Kagome
- The 8th Zhejiang Provincial Collegiate Programming Contest-> Kagome Kagome
- The 8th Zhejiang Provincial Collegiate Programming Contest / F - Kagome Kagome
- 几种任务调度的 Java 实现方法与比较
- JavaScript 自定义对象 for in
- C语言消除逗号,PS:malloc基本用法
- 汇编中函数返回结构体的方法
- 在本地配置tomcat
- ZOJ3492 Kagome Kagome
- Singleton
- 读 《think in java》 有感 -- 第(七)章
- nyist14年3月月赛题解
- 301重定向循环研究
- PullToRefreshListView实现根据拖拉的方向进行在顶部或者底部加载数据。
- DAO模型的增删改查
- ZOJ3498 Javabeans(找规律)
- Centos下安装chrome以及引发地进程调度的一些问题