Skip to content
返回

0x000e 【深基2.例1】跑步

编辑页面

题目描述

小 A 跑步速度 5 m/s5 \text{ m/s},八尾勇跑步速度 8 m/s8 \text{ m/s},八尾勇在小 A 后面 100 m100 \text{ m},他们同时起跑,请问需要多长时间八尾勇可以追上小 A?输出一个数字表示答案,使用 cout 直接输出。

输入格式

不需要输入。

输出格式

请输出一个数字表示答案,使用 cout 直接输出。

题目分析

目的:求出八尾勇追上小 A 需要的时间。

这是一个追击问题,设八尾勇追上小 A 需要的时间为 tt,则有:

8t=5t+1008 t = 5 t + 100

解得 t=1003t = \frac{100}{3}

需要注意的是,整数与整数相除得到的结果是整数,需要用浮点数表示。

代码实现

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << 100.0 / 3;
  return 0;
}

编辑页面
分享这篇文章至:

下一篇
0x000d 【深基1.习7】定期存款