http://poj.org/problem?id=3684
2.Idea
Assume each of ball is transparent and could pass by one another when collide.
3.Source
#define MAX_N 111
const double g = 10.0;
int N, H, R, T;
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*d;
return H - g * d *d / 2;
}
else {
double d = k * t + 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()
{
int c;
cin >> c;
while (c--) {
cin >> N >> H >> R >> T;
solve();
}
return 0;
}
No comments:
Post a Comment