728x90
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com


범위가 int 범위 안이라서
int로 해줬는데 오답이 나와서
double로 코드를 작성해주니 정답이 나왔다.
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int tc=1;tc<=t;tc++) {
double d = sc.nextInt();
double a = sc.nextInt();
double b = sc.nextInt();
double f = sc.nextInt();
double time = d/(a+b);
double ans = f*time;
System.out.printf("#"+tc+" "+"%.10f \n",ans);
}
}
}728x90
'SW Expert Academy > SWEA D3' 카테고리의 다른 글
| [SW Expert Academy] 부분 수열의 합 (D3) (0) | 2024.09.29 |
|---|---|
| [Android Studio/Kotlin] SharedPreferences (0) | 2024.09.29 |
| [SW Expert Academy] 주혁이의 복권 당첨 (D3) (0) | 2024.09.28 |
| [SW Expert Academy] 구구단 걷기 (D3) (0) | 2024.09.28 |
| [SW Expert Academy] 신뢰 (D3) (0) | 2024.09.28 |