文章

84

粉丝

2

获赞

600

访问

26.1k

头像
猴子报数 题解:
P1081 兰州大学/湖南大学机试题
发布于2026年2月2日 09:34
阅读数 254

#include<iostream>
#include<queue>

using namespace std;

int main() {
	
	int n;
	while (cin >> n && n != 0) {
		int x, y;
		cin >> x >> y;
		queue<int> q;
		for (int i = x; i <= n; i ++ ) q.push(i);
		for (int i = 1; i < x; i ++ ) q.push(i);
		while (q.size() > 1) {
			for (int i = 0; i < y - 1; i ++ ) {
				q.push(q.front());
				q.pop();
			}
			cout << q.front() << ',';
			q.pop();
		}
		cout << q.front() << endl;
	}
	
	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发