-
[브론즈 Ⅴ] 6749번 :: Next in line / Java백준/브론즈 2022. 4. 11. 13:50
https://www.acmicpc.net/problem/6749
6749번: Next in line
You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages c
www.acmicpc.net
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int Y = scan.nextInt(); int M = scan.nextInt(); int X = (M-Y) + M; System.out.println(X); } }
첫 째와 둘 째(M), 막내(Y)의 나이 차이가 동일하므로
M-Y로 둘의 나이차이를 구하고, M을 더해 첫 째의 나이를 구함
'백준 > 브론즈' 카테고리의 다른 글
[브론즈 Ⅴ] 8370번 :: Plane / Java (0) 2022.04.13 [브론즈 Ⅴ] 7287번 :: 등록 / Java (0) 2022.04.13 [브론즈 Ⅴ] 5554번 :: 심부름 가는 길 / Java (0) 2022.04.10 [브론즈 Ⅴ] 5522번 :: 카드 게임 / Java (0) 2022.04.10 [브론즈 Ⅴ] 5339번 :: 콜센터 / Java (0) 2022.04.10