文章

70

粉丝

0

获赞

225

访问

6.8k

头像
猴子报数 题解:set容器
P1081 兰州大学/湖南大学机试题
发布于2026年3月19日 16:10
阅读数 45

#include<stdio.h>
#include<string.h>
#include<map>
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;


int main(){
    int n,s,m;
    while(cin>>n>>s>>m){
        if(n==0 || s==0 || m==0) break;
        set<int> mon;
        for(int i=1; i<=n; i++) mon.insert(i);

        set<int>::iterator it=mon.begin();
        advance(it,s-1);  //从第s个猴子开始
        bool flag=1;
        int k=m;
        while(mon.size()){
            k--;
            if(k==0){
             &n...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发