시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 715 414 300 69.767%

문제

250마일 길이의 철로 양 끝에 두 기차 A와 B가 있다. A는 시속 10마일, B는 시속 15마일로 서로를 향해 출발했다. 두 기차의 출발과 동시에 기차 A 앞에 붙어있던 파리 한 마리가 기차가 충돌할 때 까지 시속 20마일로 두 기차를 사이를 왔다갔다 한다. 이때, 파리가 이동한 거리는 몇 마일일까?

폰 노이만은 문제를 듣자마자 머리속으로 무한 급수를 이용해 계산한 다음 1초도 지나지 않은 시간에 200 마일이라고 대답했다. 

철로의 길이 D, 두 기차 A, B의 속도와 파리의 속도 F가 주어졌을 때, 위 문제의 답을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 P (1 ≤ P ≤ 1000)가 주어진다.

각 테스트 케이스는 다섯 숫자 N, D, A, B, F이루어져 있다. N은 테스트 케이스의 번호이고, D는 철로의 길이 (10 ≤ D ≤ 1000), A와 B는 두 기차의 속도 (1 ≤ A, B ≤ 30), F는 파리의 속도 (A ≤ B < F ≤ 50)이다. D, A, B, F는 실수이다. 실수는 최대 소수점 둘째자리까지 주어진다.

출력

각 테스트 케이스마다 테스트 케이스 번호를 출력하고, 두 기차가 충돌할 때까지 파리가 움직인 거리를 출력한다. 절대/상대 오차는 10-2까지 허용한다.

예제 입력 1

5
1 250 10 15 20
2 10.7 3.5 4.7 5.5
3 523.7 15.3 20.7 33.3
4 1000 30 30 50
5 500 15 15 25

예제 출력 1

1 200.00
2 7.18
3 484.42
4 833.33
5 416.67
W3sicHJvYmxlbV9pZCI6Ijk0NjkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzZjAgXHViMTc4XHVjNzc0XHViOWNjIiwiZGVzY3JpcHRpb24iOiI8cD4yNTBcdWI5YzhcdWM3N2MgXHVhZTM4XHVjNzc0XHVjNzU4IFx1Y2NhMFx1Yjg1YyBcdWM1OTEgXHViMDVkXHVjNWQwIFx1YjQ1MCBcd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G5cclxuPHA+RWFjaCBkYXRhIHNldCBjb25zaXN0cyBvZiBhIHNpbmdsZSBsaW5lIGNvbnRhaW5pbmcgZml2ZSB2YWx1ZXM6IGFuIGludGVnZXIgTiAodGhlIGRhdGEgc2V0IG51bWJlciksIGFuZGZvdXIgZmxvYXRpbmctcG9pbnQgdmFsdWVzOiBEICh0aGUgaW5pdGlhbCBkaXN0YW5jZSBiZXR3ZWVuIHRoZSBiaWN5Y2xlcywgMTAgJmxlOyBEICZsZTsgMTAwMCksIEEgKGN5Y2xpc3QgQSYjMzk7c3NwZWVkIGluIG1pbGVzIHBlciBob3VyLCAxICZsZTsgQSAmbGU7IDMwKSwgQiAoY3ljbGlzdCBCJiMzOTtzIHNwZWVkIGluIG1pbGVzIHBlciBob3VyLCAxICZsZTsgQiAmbGU7IDMwKSwgYW5kIEYgKHRoZWZseSYjMzk7cyBzcGVlZCBpbiBtaWxlcyBwZXIgaG91ciwgQSAmbGU7IEImbHQ7IEYgJmxlOyA1MCkuPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+Rm9yIGVhY2ggZGF0YSBzZXQgdGhlcmUgaXMgb25lIGxpbmUgb2Ygb3V0cHV0LiBJdCBjb250YWlucyB0aGUgZGF0YSBzZXQgbnVtYmVyIGZvbGxvd2VkIGJ5IGEgc2luZ2xlc3BhY2UsIGZvbGxvd2VkIGJ5IHRoZSBudW1iZXIgb2YgbWlsZXMgdHJhdmVsZWQgYnkgdGhlIGZseSwgKHRoZSBzdW0gb2YgdGhlIGluZmluaXRlIHNlcmllcyBkZXNjcmliZWQgYnl0aGUgaW5wdXQgdmFsdWVzKSwgYWNjdXJhdGUgdG8gdHdvIGRlY2ltYWwgcGxhY2VzLjxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

ACM-ICPC > Regionals > North America > Greater New York Region > 2013 Greater New York Programming Contest B번