ccf201712-2游戏

队列应用

import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        LinkedList<Integer> queue = new LinkedList<>();
        int total = scanner.nextInt();
        int k = scanner.nextInt();
        int count = 0;
        for(int i = 1; i <= total; i++){
            queue.offer(i);
        }
        while (!queue.isEmpty()){
            if(queue.size() == 1){
                break;
            }
            count++;
            int tmp = queue.poll();
            int gewei = count%10;
            if(count % k != 0 && gewei != k){
                queue.offer(tmp);
            }
        }
        System.out.println(queue.poll());
    }
}

相关推荐

  1. ccf201712-2游戏

    2024-04-13 02:28:01       40 阅读
  2. ccf201512-1数位之和

    2024-04-13 02:28:01       32 阅读
  3. C++ //CCF-CSP计算机软件能力认证 201312-2 ISBN号码

    2024-04-13 02:28:01       44 阅读
  4. 【CSP试题回顾】201912-2-回收站选址(优化)

    2024-04-13 02:28:01       39 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-13 02:28:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-13 02:28:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-13 02:28:01       82 阅读
  4. Python语言-面向对象

    2024-04-13 02:28:01       91 阅读

热门阅读

  1. 替换服务器的SSL证书有什么影响?

    2024-04-13 02:28:01       39 阅读
  2. 数据库迁移平台构思001

    2024-04-13 02:28:01       30 阅读
  3. 自回归模型

    2024-04-13 02:28:01       29 阅读
  4. jQuery笔记 01

    2024-04-13 02:28:01       36 阅读
  5. 循环控制语句的实际应用(3)

    2024-04-13 02:28:01       36 阅读
  6. Python:生成器

    2024-04-13 02:28:01       34 阅读
  7. 迷宫-蓝桥602-bfs-2019省赛

    2024-04-13 02:28:01       39 阅读
  8. spispi

    spispi

    2024-04-13 02:28:01      31 阅读
  9. 【C++】C++11介绍

    2024-04-13 02:28:01       35 阅读