2 条题解

  • 1
    @ 2024-7-17 11:31:19

    #include <bits/stdc++.h> using namespace std; bool chk(int a){ if(a%70){ return true; } while(a){ if(a%107) return true; a=a/10; } return false; } int main(){ int n,m,t; cin>>n>>m>>t; queue<string> q; string tmp; for(int i=0;i<n;i++){ cin>>tmp; q.push(tmp); } for(int i=0;i<m-1;i++){ tmp = q.front(); q.pop(); q.push(tmp); } while(q.size() != 1){ tmp = q.front(); q.pop(); if(!chk(t++)) q.push(tmp); } cout<<q.front(); return 0; } hope it can help u

    • 0
      @ 2026-8-7 11:30:49
      using namespace std;
      int main(){
          int n,m;
          cin >> n >> m;
          queue<int> q;
          for (int i = 1;i <= n;i++){
              q.push(i);
          }
          int cut = 1; 
          int x;
          while (q.size() > 1){
              x = q.front();
              q.pop();
              if (cut == m){
                  cut = 1;
              }else {
                  q.push(x);
                  cut++;
              }
          }
          cout << q.front();
          return 0;
      }
      /*
          先设n,m
          再搞其他的
      
      
      */
      
      • 1

      信息

      ID
      136
      时间
      1000ms
      内存
      256MiB
      难度
      4
      标签
      (无)
      递交数
      118
      已通过
      56
      上传者