7 条题解

  • 4
    @ 2023-7-26 16:40:28

    话说这是个数学题?牛吃草问题啊

    #include <bits/stdc++.h>
    using namespace std;
    int x,a,y,b;
    double num;
    int main()
    {
        cin >> x >> a >> y >> b;
        num = 1.0 * (y*b - x*a) / (b - a);
        cout << fixed << setprecision(2) << num;
        return 0;
    }
    

    牛吃草问题又叫牛顿问题

    “牛吃草问题”主要有两种类型:

    1、求时间

    2、求头数

    除了总结这两种类型问题相应的解法,在实践中还要有培养运用“牛吃草问题”的解题思想解决实际问

    题的能力。

    ①在求出“每天新生长的草量”和“原有草量”后,已知头数求时间时,我们用“原有草量÷每天实际减少

    的草量(即头数与每日生长量的差)”求出天数。

    ②已知天数求知数时,同样需要先求出“每天新生长的草量”和“原有草量”。

    ③根据“(原有草量”+若干天里新生草量)÷天数”,求出只数。

    根据题目要求,这里每日生长量就是答案(没有除以1在程序里不扣分,学校考试嘛···你可以试试)

    • 3
      @ 2023-5-21 16:33:24

      这道题,本来挺简单的,但不知道为什么一些本来对的答案,显示不通过

      这是正确代码

      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	 int x,y,a,b;
      	 double z;
      	 scanf("%d%d%d%d",&x,&a,&y,&b);
      	 z=(b*y-a*x)/(b-a);
      	 printf("%.2f\n",z);
      	return 0;
      }
      

      这是别的代码,本来是对的,但不知道为啥显示0分

      #include<bits/stdc++.h>   //也可用iostream库和cstdio库
      using namespace std;
      int main()
      {
      double a,b,x,y,z;
      cin>>x>>a>>y>>b;
      z=(y*b-x*a)/(b-a);
      printf("%.2lf\n",z);
      return 0;
      }
      

      image image image 第二个代码在一本通没事,在这里显示错

    • 1
      @ 2023-5-22 23:45:45

      x,a,y,b=input().split()

      x=int(x)

      y=int(y)

      a=int(a)

      b=int(b)

      z=(ax-by)/(a-b)

      print("%.2f"%z)

    • 0
      @ 2024-4-21 15:01:40
      ```
      
      #include <iostream>
      #include <iomanip>
      using namespace std;
      int main()
      {
      int x, a, y, b;
      double q;
      cin >> x >> a >> y >> b;
      q = (x*a-y*b)/(b-a);
      cout << fixed << setprecision(2) << q;
      return 0;
      }
      
      ```
      哪位大佬告诉我为什么是负数?😕 
      ```
      • 0
        @ 2024-4-6 21:20:57
        #include <iostream>
        #include <cstdio>
        #include <cmath>
        using namespace std;
        int main()
        {
            int x,a,y,b;
            double ans;
        	cin >> x >> a >> y >> b;
            ans = (y * b - x * a) / (b - a);
            printf("%.2f",ans);
        	return 0;	
        }
        //谁帮我看一下为什么是零分
        
        • 0
          @ 2023-5-29 19:39:45

          解析: 1、这里我们需要明确:现有资源加上新生资源可以让xx亿人消耗aa年,让yy亿人消耗bb年; 那么这里我们可以得到b年后的资源为 yby*baa年后的资源为xax*a; 2、已经知道现在资源是固定的,那么bb年后的资源-aa年后的资源,除以bbaa年的跨度(ba)(b-a)就可以算出每年的新生资源; 3、只要消耗的资源不超过新生资源,就不会枯竭,也就是题目要求的内容 PS:要注意数据类型的转换,题目输出的都是intint类型,最后的输出是doubledouble类型

          参考代码:

          #include <bits/stdc++.h>
          using namespace std;
          int x,a,y,b;//定义题目所需要的变量x,a,y,b;
          double num;//最后的结果是浮点数类型
          int main()
          {
              cin >> x >> a >> y >> b;
              num = 1.0 * (y*b - x*a) / (b - a);//1.0*(y*b - x*a) 可以进行数据类型转换
              cout << fixed << setprecision(2) << num;//注意题目要求保留两位小数
              return 0;
          }
          
          • -1
            @ 2023-7-25 20:12:39

            拿走不谢

            #include<bits/stdc++.h>  
            using namespace std;
            int main(){
            double a,b,x,y,z;
            cin>>x>>a>>y>>b;
            z=(y*b-x*a)/(b-a);
            printf("%.2lf\n",z);
            return 0;
            }
            
            
            • 1

            信息

            ID
            106
            时间
            1000ms
            内存
            256MiB
            难度
            5
            标签
            递交数
            330
            已通过
            132
            上传者