2 条题解

  • 2
    @ 2023-1-17 16:39:24
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n, x, y, t, i;//t代表剩余的钱
    	cin >> n >> x >> y;
    	//循环霸王龙可能买到的只数范围
    	for(i = 1; i <= (n - y) / x; i++){
    		//计算买完霸王龙剩余的钱
    		t = n - i * x;
    		//判断条件
    		//t % y == 0 判断不能有钱剩下, 买完霸王龙之后的钱正好可以买三角龙 
    		if(t % y == 0 && i >= t / y && i + t / y >= 5){
    			cout << i << " " << t / y << endl;
    		}
    	} 
    	return 0;
    }
    
    
    • 1
      @ 2023-10-14 19:26:10

      先赞后搬

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

      信息

      ID
      391
      时间
      1000ms
      内存
      16MiB
      难度
      1
      标签
      递交数
      49
      已通过
      34
      上传者