7 条题解

  • 5
    @ 2023-8-1 15:54:45

    俗话说得好:暴力出奇迹!意思是:你只管暴力,剩下的交给奇迹!

    #include <bits/stdc++.h>
    using namespace std;
    long long x, y, n, sumx = 1, sumy = 1;
    int main()
    {
        cin >> x >> y >> n;
        for (int i = 1; i <= n; i++)
        {
            if (sumx > x)
            {
                sumx = 1;
            }
            if (sumy > y)
            {
                sumy = 1;
            }
            cout << sumx << " " << sumy << endl;
            sumx++;
            sumy++;
        }
        return 0;
    }
    

    熟悉的抱走流程又来了!点赞 → 抱走

    • 3
      @ 2022-7-3 15:11:14

      这题不难发现,其实每次输出就是反复输出了队员的编号。

      比如说 x=3,y=5,n=5x = 3 , y = 5 , n = 5 的时候

      输出为(括号里面自行省略)

      (n = 1) 1 1 
      
      (n = 2) 2 2
      
      (n = 3) 3 3
      
      (n = 4) 1 4
      
      (n = 5) 2 5
      

      按照这个思路,即可写出 AC 代码(甚至不用数组)。

      code( 3ms )

      #include <cstdio>
      using namespace std;
      
      int x , y , n;
      int i = 1 , j = 1;
      
      int main(void){
      	scanf("%d%d%d" , &x , &y , &n);
      	while(n--){
      		printf("%d %d\n" , i++ , j++);
      		if(i > x) i = 1;
      		if(j > y) j = 1;
      	}
      }
      
      • 2
        @ 2022-6-11 19:31:47

        这道题用队列会比较好

        #include <bits/stdc++.h>//用万能头是一个好习惯
        #include <queue>//要用队列的头文件
        using namespace std;
        queue<int> a1 , a2;
        int n1 , n2 , n;
        int main()
        {
        	cin >> n1 >> n2;
        	cin >> n;
        	for(int i = 1;i <= n1;i++)
        	    a1.push(i);
        	for(int j = 1;j <= n2;j++)
        	    a2.push(j);
        	for(int i = 1; i <= n;i++)
        	{
        		cout << a1.front() << " " << a2.front() << endl;
        		a1.push(a1.front());
        		a2.push(a2.front());
        		a1.pop();
        		a2.pop();
        	}
        	return 0;
        }
        
        • 1
          @ 2023-6-5 15:23:37

          暴力求解我爱你,适合像我这样子的傻瓜

          #include <bits/stdc++.h>//暴力求解我爱你
          using namespace std;
          int x,y,n,sumx=1,sumy=1;
          int main(){   
              cin>>x>>y>>n;
              for(int i=1;i<=n;i++){
                  if(sumx>x)
                      sumx=1;
                  if(sumy>y)
                      sumy=1;
                  cout<<sumx<<' '<<sumy<<'\n';
                  sumx++;
                  sumy++;
              }
              return 0;
          }
          
          
          
          </span>
          • -2
            @ 2023-3-26 12:16:49

            先进队,再出队

            for (int i=1;i<=n;i++)
            {
                cout<<a1.front()<<" "<<a2.front()<<'\n';
                a1.push(a1.front());
                a2.push(a2.front());
                a1.pop();
                a2.pop();
            }
            
            • -3
              @ 2022-5-2 16:21:00

              #include <bits/stdc++.h> using namespace std; int n,x,y,a,b; int main() { cin>>x>>y>>n; while(n>0) { n--; if(a<x&&b<y) { a++; b++; } else if(ax&&b<y) { a=1;b++; }
              else if(b
              y&&a<x){ b=1; a++; } else { a=1;b=1; } cout<<a<<" "<<b<<endl; } return 0; }

              • -7
                @ 2022-4-24 16:50:27

                写题解请注意

                鼓励大家写题解,但注意题解格式。

                题解一定要有思路解析或代码注释,能否让别人理解你的思路

                也是你的能力的检验,不要只放无意义的代码给大家复制,那就失去了做题的初心。

                给代码两端加上这个会舒服一些

                ```cpp

                你的代码

                ```

                </span>

                这个点在键盘的左上角tab上面那个键,注意切换输入法

                #include<iostream>
                using namespace std;
                int main()
                {
                    int n;
                    cin>>n;//这是一个注释
                    return 0;
                } 
                

                请注意严禁抄袭题解,写题解不要只放代码,需加上你的思路或代码注释。

                抄袭题解一经发现直接取消成绩。

                题解被删除的可能

                1. 代码不符合格式规范
                2. 没有思路讲解或者没有注释,
                3. 无意义的题解

                大家携手共同维护一个良好的编程环境,如果一经发现,多次作乱。可能会被管理员拉黑,请注意,一旦拉黑即失去登陆资格。

                • 1

                信息

                ID
                1418
                时间
                1000ms
                内存
                256MiB
                难度
                1
                标签
                递交数
                160
                已通过
                116
                上传者