Plan garlic guest team to knock 7

Keywords: Java REST

 Time limit: 1000ms space limit: 131072K

There is a wine table game called "knock 7". The rule is to start from one person and say any number. Other people will report back in sequence. If a number contains 77, or multiple of 77, then you need to knock the cup or plate, but you can't say it.

Now nn people are sitting around a round table, they are numbered from 11 to nn clockwise. Starting from one person to report a number, others will report back in a clockwise order (plus one). If a person's number contains 77, or a multiple of 77, then he will quit the game, and the next person will continue to report until there is one person left.

Input format
In the first line, enter three integers, nn, mm, tt. nn stands for the total number of people, mm stands for the number reported from the MM person, and his number is tt. (1 \leq m \leq n \leq 10001 ≤ m ≤ n ≤ 1000, 1 \leq t \leq 1001 ≤ t ≤ 100) next nn line, enter a string for each line, representing the name of the nn person, and the length of the string shall not exceed 2020.

Output format
Output the name of the rest of the people, take a line.

sample input

5 3 20
donglali
nanlali
xilali
beilali
chuanpu

sample output

chuanpu

Realization

package www.jisuanke.ds;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author wangchong
 * @date 2019/5/3 18:32
 * @email 876459397@qq.com
 * @CSDN https://blog.csdn.net/wfcn_zyq
 * @describe
 */
public class Code_10_Say7 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        ArrayList<String> arrayList = new ArrayList<>();
        int n = input.nextInt();
        int m = input.nextInt();
        int t = input.nextInt();
        for (int i = 0; i < n; i++) {
            arrayList.add(input.next());
        }
        int index = t - 1;
        int num7 = 0;
        int i = m - 1;
        for (; i < n; i++) {
            while (arrayList.get(i).equals("wangchong")) {
                i++;
                if (i == n) {
                    i = 0;
                }
            }
            index++;
            if (index % 7 == 0 || String.valueOf(index).contains("7")) {
                arrayList.set(i,"wangchong");
                num7++;
                if (num7 == n - 1) {
                    break;
                }
            }
            if (i == n - 1) {
                i = -1;
            }
        }
        for (String str : arrayList
                ) {
            if (!str.equals("wangchong")) {
                System.out.println(str);
            }
        }

    }
}

Posted by student101 on Mon, 18 Nov 2019 12:15:26 -0800