123456789101112131415161718192021222324252627282930 |
- #include <stdio.h>
- int main() {
- int n, m;
-
- scanf("%d %d", &n, &m);
-
- double total_distance = 0.0; // 总路程
- double height_after_mth_bounce = n; // 第m次落地后的高度
-
- // 计算每次落地的情况
- int i;
- for (i = 1; i <= m; i++) {
- // 第i次落地时的落地距离
- if (i == 1) {
- total_distance += n; // 第一次落地时的距离
- } else {
- total_distance += height_after_mth_bounce * 2; // 加上反弹和下落的距离
- }
-
- // 计算第i次落地后的反弹高度
- height_after_mth_bounce /= 4.0;
- }
-
- // 输出结果,保留小数点后两位
- printf("%.2f\n", total_distance);
- printf("%.2f\n", height_after_mth_bounce);
-
- return 0;
- }
|