ZOJ 3492Kagome Kagome
来源:互联网 发布:怎样生成淘宝客链接 编辑:程序博客网 时间:2024/03/29 00:53
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.
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.
For each test case, output the name of the child who is right behind Higurashi Tewi.
32 AliceAlice Bob4 inuinu neko usagi kizune4 catdog cat rabbit fox
Bobusagifox
References
- http://en.wikipedia.org/wiki/Kagome_Kagome
#include<map>#include<cmath> #include<queue> #include<string>#include<vector>#include<cstdio> #include<cstring> #include<iostream>#include<algorithm> using namespace std;#define ms(x,y) memset(x,y,sizeof(x)) #define rep(i,j,k) for(int i=j;i<=k;i++) #define per(i,j,k) for(int i=j;i>=k;i--) #define loop(i,j,k) for (int i=j;i!=-1;i=k[i]) #define inone(x) scanf("%d",&x) #define intwo(x,y) scanf("%d%d",&x,&y) #define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z) typedef long long LL;const int low(int x) { return x&-x; }const int INF = 0x7FFFFFFF;const int mod = 1e9 + 7;const int N = 1e5 + 10;int T, n;string s, a[N];int main(){for (inone(T); T--;){inone(n); cin >> s;int k = 0;rep(i, 0, n - 1){cin >> a[i];if (a[i] == s) k = i;}cout << a[(k + n / 2) % n] << 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
- Client(客户端)测试专题技术
- gif 格式图片详细解析
- R语言 决策树--预测模型
- 使用数据库序列生成主键
- chatrr权限
- ZOJ 3492Kagome Kagome
- 【树莓派】更新软件源之后更新报错
- Bootstrap 多媒体对象和列表组
- libpng的png_read_info和png_read_image使用实例分析
- Spring MVC 静态资源访问 mvc:resources 标签
- C#封装自己的函数,并且引用
- 四种算法 Dijkstra bellman spfa Floyd 模版
- ZOJ 3497Mistwald
- Java基础程序设计(一)