공부하기/백준

[Java] 백준 풀기 6749 - Next in line

XEV 2023. 10. 24. 23:34

자바 백준 6749번

브론즈 4

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 sc = new Scanner(System.in);
        
        int youngest = sc.nextInt();
        int middle = sc.nextInt();
        
        int oldest = middle + (middle - youngest);
        
        System.out.println(oldest);
    }
    
}