Created
March 6, 2016 18:06
-
-
Save HyeonWooKim/c7c016f4c0b86fe4cc10 to your computer and use it in GitHub Desktop.
조세퍼스 문제(BOJ 1158)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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