题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#

求小球落地5次后所经历的路程和第5次反弹的高度

https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
    double height;
    cin >> height;

    double bounce = 0;
    double count = 0;
    double all = 0;

    while(count < 5){
        all += height;
        bounce = height/2;
        all += bounce;
        height = bounce;
        count++;
    }
    printf("%.6lf\n", all-height);
    printf("%.6lf", height);
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

05-16 11:16
已编辑
东华理工大学 Java
牛客73769814...:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
牛客创作赏金赛
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-29 17:30
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务