Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int main(){
- int n, m;
- cin >> n >> m;
- queue<int> q;
- for(int i=1; i<=n; i++){
- q.push(i);
- }
- int cnt=0;
- cout << "<";
- while(!q.empty()){
- cnt++;
- if(cnt == m){
- cout << q.front();
- cnt = 0;
- q.pop();
- if(!q.empty()) cout << ", ";
- }else{
- int temp=q.front();
- q.pop();
- q.push(temp);
- }
- }
- cout << ">";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement