작성일 :

문제 링크

30319번 - Advance to Taoyuan Regional

설명

TOPC 개최 예정일이 YYYY-MM-DD 형식으로 주어질 때, ICPC 타오위안 리저널 참가 마감일 이내인지 판별하는 문제입니다.


ICPC 타오위안 리저널은 2023-10-21에 시작하며, 최소 35일 전에 리스트를 제출해야 합니다. 따라서 2023-09-16 이하이면 GOOD, 이후이면 TOO LATE를 출력합니다.


접근법

년, 월, 일을 파싱하여 기준일 2023-09-16과 비교합니다. 년도가 2023보다 크거나, 월이 9보다 크거나, 월이 9이고 일이 16보다 크면 TOO LATE입니다.


Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;

class Program {
  static void Main() {
    var parts = Console.ReadLine()!.Split('-');
    var year = int.Parse(parts[0]);
    var month = int.Parse(parts[1]);
    var day = int.Parse(parts[2]);

    var lastYear = 2023;
    var lastMonth = 9;
    var lastDay = 16;

    if (year > lastYear || (year == lastYear && month > lastMonth) ||
        (year == lastYear && month == lastMonth && day > lastDay))
      Console.WriteLine("TOO LATE");
    else Console.WriteLine("GOOD");
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  const int lastYear = 2023;
  const int lastMonth = 9;
  const int lastDay = 16;

  string date; cin >> date;
  int year = stoi(date.substr(0, 4));
  int month = stoi(date.substr(5, 2));
  int day = stoi(date.substr(8, 2));

  if (year > lastYear || (year == lastYear && month > lastMonth) ||
      (year == lastYear && month == lastMonth && day > lastDay))
    cout << "TOO LATE\n";
  else cout << "GOOD\n";

  return 0;
}

Tags: 30319, arithmetic, BOJ, C#, C++, 구현, 백준, 수학, 알고리즘

Categories: ,