umilove98의 블로그

백준 1297 Java 본문

algorithm/백준

백준 1297 Java

umilove98 2021. 7. 20. 13:13
반응형

삼각형의 대각선길이 ^2 = 너비^2 + 높이^2 임을 이용하여 계산한다.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String s = bf.readLine();
		StringTokenizer st = new StringTokenizer(s); 
		int c = Integer.parseInt(st.nextToken());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		
		double h = Math.pow(c, 2) / (Math.pow(a, 2) + Math.pow(b, 2)) * Math.pow(a, 2);
		double w = Math.pow(c, 2) / (Math.pow(a, 2) + Math.pow(b, 2)) * Math.pow(b, 2);
		
		System.out.println((int)Math.sqrt(h) + " " + (int)Math.sqrt(w));

	}

}
반응형

'algorithm > 백준' 카테고리의 다른 글

백준 1037 Java  (0) 2021.07.22
백준 1018 Java  (0) 2021.07.22
백준 22193 Java  (0) 2021.07.18
백준 21300 Java  (0) 2021.07.18
백준 20492 Java  (0) 2021.07.18