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

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

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

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

int main() {
    int high;
    cin>>high;
    double s=0.0;
    double h=(double)high*pow(0.5, 5);
    s=(double)high+2*high*(0.0625+0.125+0.25+0.5);
    cout<<s<<endl;
    cout<<h;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务