WA了一个,求调
查看原帖
WA了一个,求调
1460644
Whn19770525楼主2025/7/22 18:36
#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;
}

2025/7/22 18:36
加载中...