[CodeForces Round #784] A. Division? (C++)

2022. 5. 1. 05:32

백준문제풀이 스터디 9주차

CodeForces에서 오랜만에 Div.4 수준 (백준 기준 Gold 1 이하 수준이라고 함) 문제들로 구성된 대화가 개최되었다.

해당 대회 문제를 풀고싶어서 이번 스터디에는 대회 가상 참여 (virtual participation)을 하게 되었다. 혹시 관심 있으면

아래 사이트에서 "start virtual contest"버튼을 눌러 참가해보시죠.

 

간단하게 설명드리자면 채점 방식은 ICPC와 같고, 2시간동안 진행이 된다.

 

https://codeforces.com/contest/1669

 

https://codeforces.com/contest/1669

 

codeforces.com


문제

Codeforces separates its users into 44 divisions by their rating:

  • For Division 1: 1900≤rating1900≤rating
  • For Division 2: 1600≤rating≤18991600≤rating≤1899
  • For Division 3: 1400≤rating≤15991400≤rating≤1599
  • For Division 4: rating≤1399rating≤1399

Given a ratingrating, print in which division the ratingrating belongs.

입력

The first line of the input contains an integer tt (1≤t≤1041≤t≤104) — the number of testcases.

The description of each test consists of one line containing one integer ratingrating (−5000≤rating≤5000−5000≤rating≤5000).

출력

For each test case, output a single line containing the correct division in the format "Division X", where XX is an integer between 11 and 44 representing the division for the corresponding rating.


문제 이해

if 문 사용하여 간단하게 푸는 쉬운 1번문제.


코드

#include <iostream>
using namespace std;

int main()
{
    int n;      // the number of testcases
    int x;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> x;
        cout << "Division ";
        if (x <= 1399) {
            cout << 4 << endl;
        } else if (x <= 1599) {
            cout << 3 << endl;
        } else if (x <= 1899) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    }

    return 0;
}

https://codeforces.com/contest/1669/problem/A

 

https://codeforces.com/contest/1669/problem/A

 

codeforces.com

 

BELATED ARTICLES

more