Bronze V 문제 번호 6749번 : Next in line - JAVA [자바]
728x90
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.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int y = sc.nextInt();
int m = sc.nextInt();
System.out.println(m+(m-y));
}
}
'알고리즘 > 백준 문제 및 정답' 카테고리의 다른 글
Bronze V 문제 번호 8370번 : Plane - JAVA [자바] (0) | 2022.01.31 |
---|---|
Bronze V 문제 번호 7287번 : 등록 - JAVA [자바] (0) | 2022.01.31 |
Bronze V 문제 번호 5554번 : 심부름 가는 길 - JAVA [자바] (0) | 2022.01.30 |
Bronze V 문제 번호 5522번 : 카드 게임 - JAVA [자바] (0) | 2022.01.22 |
Bronze V 문제 번호 5339번 : 콜센터 - JAVA [자바] (0) | 2022.01.22 |