PIP3 in PYTHON3 Install an error, you can’t find SSL


benchmark time limit: 1 second space limit: 131072 kb score: 0Difficulty: Basic Questions
N Personal sitting into a ring (number 1 -n), from the first person to count, the number of people who count them to K, the people behind them will be reported again from 1. Ask the number of the last people.
For example: n = 3, k = 2.2, first, then No. 1, and the last is No. 3.
2 numbers n and k, indicating n individuals, count to k. (2 <= n, k <= 10^6)
The number of people left last left
input example
3 2
OUTPUT Example

It feels that mathematical problems are so difficult …


analysis process is like this. Assuming that the first round is eliminated by the person number K-1 (the number starts from 0), then there will be a mapping relationship between the first and second rounds.

k —————–>0




k-2 ——————–> N-2 (the first round on the left, the second round on the right)

Set x as the number in the second round. According to the mapping above, there will be such a relationship (x+k)%n. The reason why N-1 individuals were mapped from the second round to the first round of N individuals.

and k = m%n, and the formula can be obtained (x+m)%n.

and pushing this way, from the second round to the third round, it is (x+m)%(n-1), so that it is recursor to the end.

I can think of the last round, there is only one person left, then he is the winner, the number is 0.

So according to the above relationship, push back, get the last round of the number 0 number in the first round, is the answer.

#include <iostream>
#include <cstdio>
#include <cstring>
#define  MAX_N 1000005
using namespace std;
int main()
    int n,k;
    int f[MAX_N];
        for(int i=2;i<=n;i++)
    return 0;


Related Posts

[Compulsory] Principles of artificial intelligence Learning Notes (1) Chapter1 Introduction

pyTorch Realization Relationship Exclusion

Drag -Drag progress bar display progress

webView and JS interact all methods and use

PIP3 in PYTHON3 Install an error, you can’t find SSL

Random Posts

Ruby basic knowledge (1)

bzoj1677: [USACO2005 JAN] SumSets

Ubuntu system linux installation Pytesseract and Tesseract-OCRCAOMEI

Openark installation tutorial

Suning “sells unable to sell”