2014ACM集训13级PK赛2-Kagome Kagome
2014-03-09 22:08
387 查看
Description
Translation:
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
Sample Output
Bobusagifox
References
http://en.wikipedia.org/wiki/Kagome_Kagome
Kagome kagome, kago no naka no tori wa Itsu itsu deyaru? Yoake no ban ni Tsuru 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
3 2 Alice Alice Bob 4 inu inu neko usagi kizune 4 cat dog cat rabbit fox
Sample Output
Bobusagifox
References
http://en.wikipedia.org/wiki/Kagome_Kagome
#include <stdio.h> #include <string.h> #include <stdlib.h> char name[100],s[1000][100]; int main() { int N; scanf ("%d%*c",&N); while (N--) { int n,i; scanf ("%d %s",&n,name); for (i = 0;i < n;i++) scanf ("%s",s[i]); for (i = 0;i < n;i++) if (!strcmp(name,s[i])) break; int ans = (i + n / 2) % n; puts (s[ans]); } return 0; }
相关文章推荐
- 2014ACM集训13级PK赛2-Somali Pirates
- 2014ACM集训13级PK赛3-Hard to Play
- 2014ACM集训13级PK赛2-An Awful Problem
- 2014ACM集训13级PK赛3-Java Beans
- 2014ACM集训13级PK赛2-Wu Xing
- 2014ACM集训13级PK赛2-Ordinal Numbers
- 2014ACM集训13级PK赛4-Second-price Auction
- 2014ACM集训13级PK赛2-Conic Section
- 2014ACM集训13级PK赛4-80ers' Memory
- 2014ACM集训13级PK赛2-Javabeans
- 2014ACM集训13级PK赛4-A Stack or A Queue?
- 2014ACM集训13级PK赛2-Median
- 2014ACM集训13级PK赛4-K-Nice
- 2014ACM集训13级PK赛4-Light Bulb
- 2014ACM集训13级PK赛3-Draw Something Cheat
- 2014ACM集训13级PK赛3-Modular Inverse
- 2014ACM集训13级PK赛5- Accurately Say "CocaCola"!
- 2014ACM集训13级PK赛3-Yet Another Story of Rock-paper-scissors
- 2014ACM集训13级PK赛3-Break Standard Weight
- 2014ACM集训13级PK赛5-Easy Task