Logo
(追記) (追記ここまで)

24638번 - Anno Domini 2022 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB25018813977.654%

문제

Soon we will celebrate New Year 2022, but what does this number mean? As you possibly know, this dating system was invented in AD 525 by Dionysius Exiguus. He chose the birth of Jesus Christ as the starting point of the Years of Our Lord (Anno Domini in Latin, AD for short). All the years before that were counted backwards as years Before Christ (BC for short).

An interesting detail of this dating system is that there is no year 0 --- year 1 BC is immediately followed by AD 1. Because of that, sometimes it is quite tricky to find time difference between two dates if these dates belong to two different eras.

To simplify this task, please write a program that computes how many years passed between January 1st of two years given in the input.

입력

Two years are specified on two sequential input lines. Each year is specified in one of two forms:

  1. as letters AD, followed by a space and a positive integer without leading zeroes in range 1ドル..9999$;
  2. as a positive integer without leading zeroes in range 1ドル..9999,ドル followed by a space and letters BC.

The years may be specified in arbitrary order --- the earlier year is not necessarily given first.

출력

The only line of the output must contain one integer: the number of years that passed between January 1st of the earlier year and January 1st of the later year.

제한

예제 입력 1

1 BC
AD 1

예제 출력 1

1

예제 입력 2

AD 1
AD 2001

예제 출력 2

2000

예제 입력 3

AD 2022
5508 BC

예제 출력 3

7529

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2021-2022 North-Western Russia Regional Contest A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /