Skip to content

Instantly share code, notes, and snippets.

@HyeonWooKim
Created March 6, 2016 18:06
Show Gist options
  • Save HyeonWooKim/c7c016f4c0b86fe4cc10 to your computer and use it in GitHub Desktop.
Save HyeonWooKim/c7c016f4c0b86fe4cc10 to your computer and use it in GitHub Desktop.
조세퍼스 문제(BOJ 1158)
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int n,m,d;
vector<int> v;
cin>>n>>m;
d=m-1;
for(int i=1;i<=n;i++) v.push_back(i);
printf("<");
for(int i=0;i<n;i++)
{
auto it=v.begin();
cout<<*(it+d);
v.erase(it+d);
d+=m-1;
if(v.empty())break;
d%=v.size();
printf(", ");
}
printf(">");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment