当前位置:网站首页>The problem of Joseph in Informatics
The problem of Joseph in Informatics
2022-06-12 13:23:00 【Xiao Liu wants to be number one】
2037:【 example 5.4】 Joseph's question
The time limit : 1000 ms Memory limit : 65536 KB
Submission number : 10954 Passing number : 5588
【 Title Description 】
NN A circle of individuals , Count from the first person , Count to MM People out of circles ; Then the next person starts counting , Count to MM People out of circles ;… Output the number of people who circle in turn .
【 Input 】
Input NN and MM.
【 Output 】
Output one line , Number the people in the circle in turn .
【 sample input 】
8 5【 sample output 】
5 2 8 7 1 4 6 3【 Tips 】
【 Data range 】
For all the data ,2≤N,M≤10002≤N,M≤1000.
#include <iostream>
using namespace std;
int main()
{
int m, n, a[1000], i;
cin >> n >> m;
for (i = 0; i < n; i++)
a[i] = i + 1;// Everyone's serial number
int x = 0, y = 0;//x Is the number of people kicked ,y That's the number
i = 0;
while (x < n)
{
if (a[i] != 0)
y++;
if (y == m)
{
a[i] = 0;// After being kicked out, change its serial number to 0
y = 0;
x++;
cout << i + 1 << " ";
}
i++;
if (i == n)i = 0;// Can't write here break, If break, You can only cycle once
}
return 0;
}边栏推荐
- Script import CDN link prompt net:: err_ FILE_ NOT_ Found problem
- import torch_ Geometric loads some common datasets
- Known as the next generation monitoring system! See how awesome it is
- unittest框架
- Openmax (OMX) framework
- [embedded] serial communication and its case
- How to solve the problem of data table query error when SQLite writes the registration function?
- 嵌入式驱动程序设计
- Semantic segmentation with pytorch
- 创新实训(十二)项目总结
猜你喜欢

嵌入式驱动程序设计

成功定级腾讯T3-2,万字解析

嵌入式系统概述2-嵌入式系统组成和应用

微信web开发者工具使用教程,web开发问题

Successful job hopping Ali, advanced learning

Further understanding of the network

C#DBHelper_FactoryDB_GetConn

安装MySQL时出错,照着下面这个链接,做到cmd就不行了

Overview of embedded system 3- development process, learning basis and methods of embedded system
![[EDA] chip layout design: VLSI layout design using electric](/img/a1/da0739070c940b36bc7a55d8eb2fe5.jpg)
[EDA] chip layout design: VLSI layout design using electric
随机推荐
Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
C#DBHelper_ FactoryDB_ GetConn
C#DBHelper_FactoryDB_GetConn
JVM 运行时参数
hudi 键的生成(Key Generation)
Wechat web developer tools tutorial, web development issues
Tensorrt, onnx to tensorrt in mmclas
How to solve the problem of data table query error when SQLite writes the registration function?
Unittest framework
Newoj week 10 question solution
【云原生 | Kubernetes篇】深入了解Ingress
Chaotic engineering practice of distributed kV storage in station B
基于华为云鲲鹏弹性云服务器ECS部署openGauss数据库【这次高斯不是数学家】
torch_geometric mini batch 的那些事
One line of code to implement shell if else logic
Innovation training (x) advanced interface beautification
单向环形链表实现约瑟夫环
Installation of pagoda
Getting to know blob objects
成功跳槽阿里,进阶学习