zoukankan      html  css  js  c++  java
  • Kagome Kagome(简单)

    3492 - Kagome Kagome

    时间限制: Java: 2000 ms / Others: 2000 ms
    内存限制: Java: 65536 KB / Others: 65536 KB

    问题描述

    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.

    输入说明

    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.

    输入样例

    3
    2 Alice
    Alice Bob
    4 inu
    inu neko usagi kizune
    4 cat
    dog cat rabbit fox

    输出样例

    Bob
    usagi
    fox
    
    
    References
    
    	http://en.wikipedia.org/wiki/Kagome_Kagome

    来源

    The 8th Zhejiang Provincial Collegiate Programming Contest
     
     1 #include <iostream>
     2 #include <string>
     3 #include <cstdio>
     4 #include <cmath>
     5 #include <cstring>
     6 #include <algorithm>
     7 #include <map>
     8 #include <vector>
     9 #include <set>
    10 #include <queue>
    11 #include <stack>
    12 #define LL long long
    13 #define MAXI 2147483647
    14 #define MAXL 9223372036854775807
    15 #define eps (1e-8)
    16 #define dg(i) cout << "*" << i << endl;
    17   
    18 using namespace std;
    19   
    20 int main()
    21 {
    22     int t, n, pos;
    23     string fro;
    24     string name[105];
    25     cin >> t;
    26     while(t--)
    27     {
    28         cin >> n >> fro;
    29         for(int i = 0; i < n; i++)
    30         {
    31             cin >> name[i];
    32             if(name[i] == fro) pos = i;
    33         }
    34         cout << name[(pos + n / 2) % n] << endl;  //注意%n
    35     }
    36     return 0;
    37 }
  • 相关阅读:
    大数据学习路线图 让你精准掌握大数据技术学习
    在AI人工智能中如何巧妙学习大数据编程,成为五十万年薪的佼佼者
    大数据学习之Hadoop快速入门
    大数据学习|小白学习大数据需要满足这六个条件你就能学好大数据
    大数据学习路线(自己制定,从零开始)
    大数据学习之路(跟着大神学习一波)
    为什么这么多人学习大数据?新手该如何上手大数据?
    大数据学习路线图 让你精准掌握大数据技术学习?
    [监督学习]GDA 高斯判别分析
    The Josephus problem
  • 原文地址:https://www.cnblogs.com/cszlg/p/2932446.html
Copyright © 2011-2022 走看看