2 条题解

  • 0
    @ 2025-7-13 11:44:56

    数学方法计算出谁跳舞

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, b, n;
        cin >> a >> b;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            int x = i % a;
            int y = i % b;
            if (x == 0)
                x = a;
            if (y == 0)
                y = b;
            // x = (i-1)%a+1;
            cout << x << " " << y << "\n";
        }
        return 0;
    }
    
    • 0
      @ 2022-11-2 15:54:12
      #include <bits/stdc++.h>
      using namespace std;
      queue<int> q1, q2;
      int a, b, n;
      int main()
      {
          cin >> a >> b >> n;
          for (int i = 1; i <= a; i++)
              q1.push(i);
          for (int i = 1; i <= b; i++)
              q2.push(i);
          for (int i = 1; i <= n; i++)
          {
              int x = q1.front();
              int y = q2.front();
              cout << x << " " << y << endl;
              q1.pop(), q2.pop();
              q1.push(x), q2.push(y);
          }
          return 0;
      }
      
      • 1

      信息

      ID
      551
      时间
      1000ms
      内存
      128MiB
      难度
      1
      标签
      (无)
      递交数
      87
      已通过
      61
      上传者