5 条题解

  • 1
    @ 2025-7-15 10:24:33
    #include<bits/stdc++.h>
    using namespace std;	
    int n,m,s,f,t;
    bool a[101];
    int main()
    {
    	cin>>n>>m;
    	for(t=1;t<=n;++t) a[t]=false;
    	f=0;
    	t=0;
    	s=0;
    	do
    	{
    		++t;
    		if(t==n+1) t=1;
    		if(a[t]==false) ++s;
    		if(s==m)
    		{
    			s=0;
    			cout<<t<<" ";
    			a[t]=true;
    			f++;
    		}
    	}
    	while(f!=n);
        return 0;
    }
    
    • 0
      @ 2025-7-14 17:31:59
       植物不战僵尸 LV 3 @ 3 分钟前 
      #include<bits/stdc++.h> 
      using namespace std;
      int n,m,s,f,t;
      bool a[101];
      int main() 
      {
      cin>>n>>m;
      cout<<endl; 
      for(t=1;t<=n;++t)
      a[t]=false; 
      f=0;
      t=0;
      s=0;
      a[t]false)++s; 
      if(sm)
      {
      s=0; cout<<t<<" "; 
      a[t]=true; 
      f++;
      } }while(f!=n); 
      return 0; }
      
      
      • 0
        @ 2025-7-14 17:25:16

        发错啦~

        using namespace std;
        
        int n, m, s, f, t;
        bool a[101]; // 根据题意开出数组大小
        
        int main() {
            cin >> n >> m; // 共n人,报到m出
            for (t = 1; t <= n; ++t) a[t] = false; // 初始化所有人未出圈
            
            f = 0; t = 0; s = 0; // 初始化计数器
            do {
                ++t; // 逐个枚举圈中的所有位置
                if (t == n + 1) t = 1; // 数组模拟环状,最后一个与第一个相连
                if (a[t] == false) ++s; // 第t个位置上有人则报数
                if (s == m) { // 当前报的数是m
                    s = 0; // 计数器清零
                    cout << t << " "; // 输出出圈人的编号
                    a[t] = true; // 标记此人已出圈
                    f++; // 出圈人数增加
                }
            } while (f != n); // 直到所有人都出圈为止
            
            return 0;
        }
        
        
        • 0
          @ 2025-7-14 17:24:31
          
          

          #include using namespace std;

          int n, m, s, f, t; bool a[101]; // 根据题意开出数组大小

          int main() { cin >> n >> m; // 共n人,报到m出 for (t = 1; t <= n; ++t) a[t] = false; // 初始化所有人未出圈

          f = 0; t = 0; s = 0; // 初始化计数器
          do {
              ++t; // 逐个枚举圈中的所有位置
              if (t == n + 1) t = 1; // 数组模拟环状,最后一个与第一个相连
              if (a[t] == false) ++s; // 第t个位置上有人则报数
              if (s == m) { // 当前报的数是m
                  s = 0; // 计数器清零
                  cout << t << " "; // 输出出圈人的编号
                  a[t] = true; // 标记此人已出圈
                  f++; // 出圈人数增加
              }
          } while (f != n); // 直到所有人都出圈为止
          
          return 0;
          

          }

          • -2
            @ 2025-7-14 17:27:25

            #include<bits/stdc++.h> using namespace std; int n,m,s,f,t; bool a[101]; int main() { cin>>n>>m; cout<<endl; for(t=1;t<=n;++t) a[t]=false; f=0; t=0; s=0; do { ++t; if(t==n+1) t+1; if(a[t]false)++s; if(sm) { s=0; cout<<t<<" "; a[t]=true; f++; } }while(f!=n); return 0; }

            • 1

            信息

            ID
            274
            时间
            1000ms
            内存
            128MiB
            难度
            7
            标签
            递交数
            43
            已通过
            9
            上传者