POJ 3684 Physics Experiment——弹性碰撞

来源:互联网 发布:dvr监控软件下载 编辑:程序博客网 时间:2024/06/06 01:50
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;int main(){    double ans[200];    int T, n, h, r, t; scanf("%d", &T);    for (int kase = 1; kase <= T; kase++) {        scanf("%d %d %d %d", &n, &h, &r, &t);        for (int i = 0; i < n; i++) {            if (t - i <= 0) {                ans[i] = h;                continue;            }            double cycle = sqrt(1.0 * h / 5.0);            int cnt = (int)((t - i) / cycle);            double tt = t - i - cycle * cnt;            if (cnt % 2) {                ans[i] = sqrt(20.0 * h) * tt - 5.0 * tt * tt;            }            else {                ans[i] = 1.0 * h - 5.0 * tt * tt;            }        }        sort(ans, ans + n);        printf("%.2lf", ans[0]);        for (int i = 1; i < n; i++) {            printf(" %.2lf", ans[i] + 2.0 * r * i / 100.0);        }        printf("\n");    }    return 0;}

原创粉丝点击