7 条题解
-
4
话说这是个数学题?牛吃草问题啊
#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
这道题,本来挺简单的,但不知道为什么一些本来对的答案,显示不通过
这是正确代码
#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; }
第二个代码在一本通没事,在这里显示错
-
0
解析: 1、这里我们需要明确:现有资源加上新生资源可以让亿人消耗年,让亿人消耗年; 那么这里我们可以得到b年后的资源为 ,年后的资源为; 2、已经知道现在资源是固定的,那么年后的资源-年后的资源,除以到年的跨度就可以算出每年的新生资源; 3、只要消耗的资源不超过新生资源,就不会枯竭,也就是题目要求的内容 PS:要注意数据类型的转换,题目输出的都是类型,最后的输出是类型
参考代码:
#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
信息
- ID
- 106
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 330
- 已通过
- 132
- 上传者