https://www.acmicpc.net/problem/18108
Question
ICPC Bangkok Regional에 참가하기 위해 수완나품 국제공항에 막 도착한 팀 레드시프트 일행은 눈을 믿을 수 없었다. 공항의 대형 스크린에 올해가 2562년이라고 적혀 있던 것이었다.
불교 국가인 태국은 불멸기원(佛滅紀元), 즉 석가모니가 열반한 해를 기준으로 연도를 세는 불기를 사용한다. 반면, 우리나라는 서기 연도를 사용하고 있다. 불기 연도가 주어질 때 이를 서기 연도로 바꿔 주는 프로그램을 작성하시오.
Input
서기 연도를 알아보고 싶은 불기 연도 y가 주어진다. (1000 ≤ y ≤ 3000)
example input
2541
Ouput
example output
1998
Answer
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int buddhismY = Integer.parseInt(br.readLine());
int diffY = 543;
System.out.println(buddhismY - diffY);
}
}
Problem Solution
입력값인 현재 불기 연도 2541과 출력값 현재 서기 연도 1998가 주어졌으므로 불기 연도와 서기 연도의 차이가 543년인 것을 알 수 있다.
Code Explanation
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
InputStreamReader 클래스로 바이트 기반 스트림을 문자 기반 스트림으로 연결시켜 준다.
BufferedReader 클래스로 사용자가 입력한 문자 스트림을 읽는다.