fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. using namespace std;
  5.  
  6. int main(){
  7. int n,k;
  8. cin>>n>>k;//k번째 데이터 제거
  9.  
  10. queue<int> q;
  11.  
  12. for(int i=1;i<=n;i++){
  13. q.push(i);
  14. }
  15.  
  16. int cnt=1;
  17.  
  18.  
  19. cout<<"<";
  20. while(!q.empty()){
  21. if(cnt==k){
  22. if(q.size()==n) cout<<q.front()<<",";
  23. else if(q.size()!=1) cout<<" "<<q.front()<<",";
  24. else if(q.size()==1) cout<<" "<<q.front();
  25. q.pop();
  26. cnt=1;
  27. }
  28.  
  29. else{
  30. int data=q.front();
  31. q.pop();
  32. q.push(data);
  33. cnt++;
  34. }
  35. }
  36. cout<<">";
  37.  
  38. }
  39.  
Success #stdin #stdout 0s 4304KB
stdin
1 1
stdout
<1,>