자바 백준 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);
}
}
'공부하기 > 백준' 카테고리의 다른 글
[Java] 백준 풀기 10103 - 주사위 게임 (0) | 2023.10.26 |
---|---|
[Java] 백준 풀기 15969 - 행복 (0) | 2023.10.25 |
[Java] 백준 풀기 10214 - Baseball (2) | 2023.10.23 |
[Java] 백준 풀기 10995 - 별 찍기 20 (2) | 2023.10.22 |
[Java] 백준 풀기 1735 - 분수 합 (0) | 2023.10.21 |