#include<iostream> #include<vector> usingnamespace std; intmain() { vector<int> a; int n,m,x=0; cout<<"Input n and m:"; cin>>n>>m; a.resize(n); for(int i=0;i<n;i++) { a[i]=i+1; } vector<int>::iterator i = a.begin(); n = 0; while (a.size() != 1) { if (i == a.end()) i = a.begin(); n++; if (n == m) { i = a.erase(i); n = 0; continue; } ++i; } cout<<"Result:"<<a[0]<<endl; return0; }