poj3684

    xiaoxiao2021-12-14  17

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

    //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; }
    转载请注明原文地址: https://ju.6miu.com/read-964056.html

    最新回复(0)