시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 655 371 275 71.802%

문제

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는 실수이다. 실수는 최대 소수점 둘째자리까지 주어진다.

출력

각 테스트 케이스마다 테스트 케이스 번호를 출력하고, 두 기차가 충돌할 때까지 파리가 움직인 거리를 소수점 셋째자리에서 반올림해 둘째자리까지 출력한다.

예제 입력 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
W3sicHJvYmxlbV9pZCI6Ijk0NjkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzZjAgXHViMTc4XHVjNzc0XHViOWNjIiwiZGVzY3JpcHRpb24iOiI8cD4yNTBcdWI5YzhcdWM3N2MgXHVhZTM4XHVjNzc0XHVjNzU4IFx1Y2NhMFx1Yjg1YyBcdWM1OTEgXHViMDVkXHVjNWQwIFx1YjQ1MC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3A+XHJcblxyXG48cD5FYWNoIGRhdGEgc2V0IGNvbnNpc3RzIG9mIGEgc2luZ2xlIGxpbmUgY29udGFpbmluZyBmaXZlIHZhbHVlczogYW4gaW50ZWdlciBOICh0aGUgZGF0YSBzZXQgbnVtYmVyKSwgYW5kZm91ciBmbG9hdGluZy1wb2ludCB2YWx1ZXM6IEQgKHRoZSBpbml0aWFsIGRpc3RhbmNlIGJldHdlZW4gdGhlIGJpY3ljbGVzLCAxMCAmbGU7IEQgJmxlOyAxMDAwKSwgQSAoY3ljbGlzdCBBJiMzOTtzc3BlZWQgaW4gbWlsZXMgcGVyIGhvdXIsIDEgJmxlOyBBICZsZTsgMzApLCBCIChjeWNsaXN0IEImIzM5O3Mgc3BlZWQgaW4gbWlsZXMgcGVyIGhvdXIsIDEgJmxlOyBCICZsZTsgMzApLCBhbmQgRiAodGhlZmx5JiMzOTtzIHNwZWVkIGluIG1pbGVzIHBlciBob3VyLCBBICZsZTsgQiZsdDsgRiAmbGU7IDUwKS48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5Gb3IgZWFjaCBkYXRhIHNldCB0aGVyZSBpcyBvbmUgbGluZSBvZiBvdXRwdXQuIEl0IGNvbnRhaW5zIHRoZSBkYXRhIHNldCBudW1iZXIgZm9sbG93ZWQgYnkgYSBzaW5nbGVzcGFjZSwgZm9sbG93ZWQgYnkgdGhlIG51bWJlciBvZiBtaWxlcyB0cmF2ZWxlZCBieSB0aGUgZmx5LCAodGhlIHN1bSBvZiB0aGUgaW5maW5pdGUgc2VyaWVzIGRlc2NyaWJlZCBieXRoZSBpbnB1dCB2YWx1ZXMpLCBhY2N1cmF0ZSB0byB0d28gZGVjaW1hbCBwbGFjZXMuPFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

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

  • 문제를 번역한 사람: baekjoon
  • 빠진 조건을 찾은 사람: doju
  • 데이터를 추가한 사람: ho94949