poj3684

类比“火柴棒上的蚂蚁”。

//184k, 0ms
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

const double g = 10.0;
const int MAX_N = 105;

int N, H, R, T, C;
double y[MAX_N];

double calc(int T) {
    if(T < 0) return H;
    double t = sqrt(2 * H / g);
    int k = (int) (T / t);
    if(k % 2 == 0) {
        double d = T - k * t;
        return H - g * d * d / 2;
    } else {
        double d = (k + 1) * t - T;
        return H - g * d * d / 2;
    }
}

void solve() {
    for(int i=0; i<N; i++)
        y[i] = calc(T - i);
    sort(y, y + N);
    for(int i=0; i<N; i++)
        printf("%.2f%c", y[i]+2*R*i/100.0, i+1==N ? '\n' : ' ');
}

int main() {

    freopen("in.txt", "r", stdin);

    scanf("%d", &C);
    while(C--) {
        scanf("%d%d%d%d", &N, &H, &R, &T);
        solve();
    }

    fclose(stdin);

    return 0;
}
posted @ 2016-12-02 15:06  StevenLuke  阅读(102)  评论(0编辑  收藏  举报