ZOJ-3492 Kagome Kagome
来源:互联网 发布:php 权限系统 面相过程 编辑:程序博客网 时间:2024/04/25 15:02
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 n 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.
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
References
- http://en.wikipedia.org/wiki/Kagome_Kagome
Author: WU, Zejun
Contest: The 8th Zhejiang Provincial Collegiate Programming Contest
原题:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3492
题意:Higurashi Tewi和n个人一起玩一个叫 Kagome Kagome的游戏,给你除Higurashi Tewi外的人数,即n;和各自的名字。n后面输入的是正对着Higurashi Tewi的人的名字。让你求出背对着Higurashi Tewi的人的名字
水题,记录正对着Higurashi Tewi的人的下标,因为玩家都是均分的站的,易求出题目所求
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>using namespace std;int main(){ string n[105]; string H; int a,tem; int T; cin>>T; while(T--) { cin>>a>>H; for(int i=0;i<a;i++) { cin>>n[i]; if(n[i]==H) { tem=i; } } cout<<n[(tem+a/2)%a]<<endl; } return 0;}
- zoj 3492 Kagome Kagome
- zoj 3492 Kagome Kagome
- ZOJ 3492 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
- ZOJ 3488 Kagome Kagome
- Kagome Kagome
- F Kagome Kagome
- ZOJ3492 Kagome Kagome
- ZOJ3492-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
- Install GraphLab Create 小困扰
- python 压缩文件
- Java容器
- [UOJ#74][UR #6]破解密码(数学相关)
- ResourceBundle国际化资源文件
- ZOJ-3492 Kagome Kagome
- 设置SQL*Plus的登录配置
- 算法训练 最大最小公倍数
- PAT 1018 锤子剪刀布
- POJ 3902 The Bad Number 已被翻译
- 水一水
- BLE CoC in Android
- 解决TableView刷新指定行时闪烁的问题
- 高仿Coach蔻驰2016春季系列包包