当前位置:网站首页>029:陶陶摘苹果
029:陶陶摘苹果
2022-07-21 05:15:00 【龙星尘】
029:陶陶摘苹果
总时间限制:
1000ms
内存限制:
65536kB
描述
陶陶家的院子里有一棵苹果树,每到秋天树上就会结出10个苹果。苹果成熟的时候,陶陶就会跑去摘苹果。陶陶有个30厘米高的板凳,当她不能直接用手摘到苹果的时候,就会踩到板凳上再试试。
现在已知10个苹果到地面的高度,以及陶陶把手伸直的时候能够达到的最大高度,请帮陶陶算一下她能够摘到的苹果的数目。假设她碰到苹果,苹果就会掉下来。
输入
包括两行数据。第一行包含10个100到200之间(包括100和200)的整数(以厘米为单位)分别表示10个苹果到地面的高度,两个相邻的整数之间用一个空格隔开。第二行只包括一个100到120之间(包含100和120)的整数(以厘米为单位),表示陶陶把手伸直的时候能够达到的最大高度。
输出
包括一行,这一行只包含一个整数,表示陶陶能够摘到的苹果的数目。
样例输入
100 200 150 140 129 134 167 198 200 111 110
样例输出
5
来源
NOIP2005复赛 普及组 第一题
我们可以看看来源,哇!普及组第一题,难度这么高,但是看到年份以及“复赛”两个字后,我就不这么觉得了,现在的普及组比以前的普及组难度提高了很多,所以不必大惊小怪了。
这道题关键就是判断,我们可以判断每个苹果的高度是否小于等于淘气的最大高度加上30cm,如果是的话,将一个变量的值加一,重复执行10次,最后输出这个变量,就是淘气所能摘到的最多数量。
代码:
#include <iostream>
using namespace std;
int main()
{
int a[10];
for(int i=0;i<10;i++)
cin>>a[i];
int b,sum=0;
cin>>b;
for(int i=0;i<10;i++)
if(b+30>=a[i])
sum++;
cout<<sum;
}
只有短短的14行代码,少吧!
以后看到描述非常的多的题,不必惊慌,要好好审题,说不定问题长的,题目简单呢?
边栏推荐
- What are the functions and application industries of testing equipment development?
- 机器学习-频率派vs贝叶斯派
- 西瓜书第三章-线性模型
- Learn multithreading, process and development board together
- 01- fundamentals of automated testing -- (selenium eight part + environment configuration + eight positioning)
- 取石子
- "Running image technology" obtained Angel + financing to build a new generation of real-time data infrastructure platform
- Advanced visual studio features
- 概率论-最大似然估计
- 概率论-方差和协方差、相关系数
猜你喜欢
04 cadre d'essai de l'unit é unitest
Source Insight 4.0个性化设置及快捷键
庖丁解牛斐波拉契数列和背包问题——详细解析两个问题优化过程,带你从最基本的问题看懂动态规划!!!
「跑象科技」获得天使+融资,打造新一代实时数据基础平台
快速排序
226. 翻转二叉树
流批一体?实时数据处理场景化应用实例~
线性回归大结局(岭(Ridge)、 Lasso回归原理、公式推导),你想要的这里都有
Advanced visual studio features
In depth analysis of ArrayList source code, from the most basic capacity expansion principle, to the magic iterator and fast fail mechanism, you have everything you want!!!
随机推荐
This Bluetooth chip giant aims at the WiFi SOC market and launches a low-power WiFi MCU product line
994. 腐烂的橘子
火爆社区的开源数据可视化工具 datart 新用户体验教程
Online JVM memory problem location
Teach you how to use yolov4 training and testing data set on the server (nanny level)
面试官:你的update 更新影响行数做判断了吗?
牛客网刷题总结--面试必刷top101
Principles and advantages of wireless charging module development
567. 字符串的排列
Pytorch2onnx2Tensorflow的环境准备win10
04 unittest unit test framework
深入剖析多重背包问题(下篇)
14. 最长公共前缀
01-自动化测试基础--(selenium八股文部分+环境配置+八大定位)
Open source data visualization tool datart new user experience tutorial for popular communities
05 unittest extension
子序列
Explain the principle, classification and function of microphone array in detail
006:浮点型数据类型存储空间大小
概率论-最大似然估计