RE求助
查看原帖
RE求助
316827
Temperature_automata楼主2021/7/29 22:52

RT,全RE,本地测能过。 代码:

#include <iostream>
#include <cstdio>
#include <list>

using namespace std ;

int n , m ;
list <int> s ;
int cnt ;

int main ( ) {

	cin >> n >> m ;
	
	for ( int i = 1 ; i <= n ; i ++ ) {
		s.push_back(i) ;
	}
	
	list<int>::iterator it,now ;
	it = s.begin() ;
	while(!s.empty()) {
		cnt ++ ;
		now = it ;
		if(cnt==m) {
			cnt = 0 ;
			cout << *it << " " ;
			s.erase(it) ;
			it = now ;
		}
		if(++it==s.end()) it = s.begin() ;
	}

  return 0 ;
}

2021/7/29 22:52
加载中...