社区讨论
WA了一个,求调
P1426小鱼会有危险吗参与者 3已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mdeehvvp
- 此快照首次捕获于
- 2025/07/22 18:37 7 个月前
- 此快照最后确认于
- 2025/11/04 03:55 4 个月前
CPP
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double s, x;
cin >> s >> x;
double distance = 0;
double speed = 7;
double next_distance;
for (int t = 1; ; t++) {
distance += speed;
next_distance = distance + speed * 0.98;
if (distance >= s - x && distance <= s + x) {
if (next_distance > s + x || next_distance < s - x) {
speed *= 0.98;
continue;
} else {
cout << "y" << endl;
return 0;
}
}
if (distance > s + x) {
cout << "n" << endl;
return 0;
}
speed *= 0.98;
}
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...