Skip to content

Instantly share code, notes, and snippets.

@nineteeneightyfour1219
Created October 30, 2020 05:37
Show Gist options
  • Save nineteeneightyfour1219/6a41b742d8c0ac236a1b0f4364ee6352 to your computer and use it in GitHub Desktop.
Save nineteeneightyfour1219/6a41b742d8c0ac236a1b0f4364ee6352 to your computer and use it in GitHub Desktop.
BOJ 11866(요세푸스 문제)
#include<iostream>
#include<queue>
using namespace std;
int main(){
int N,K;
cin >> N;
cin >> K;
queue<int> q;
for (int i=1;i<=N;i++){
q.push(i);
}
int temp;
cout << "<";
while (N--){
temp = 0;
for (int i=1;i<=K;i++){
temp = q.front();
if (i==K){
q.pop();
cout << temp ;
if (N!=0) cout << ", ";
}
else{
q.pop();
q.push(temp);
}
}
}
cout << ">";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment