Codeforces 1669A Division? Solution & Explanation

Difficulty : 800

Problem Description

Codeforces separates its users into 4 divisions by their rating:

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

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

Input

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

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

Output

For each test case, output a single line containing the correct division in the format “Division X”, where X is an integer between 1 and 4 representing the division for the corresponding rating.

Examples

Input7
-789
1299
1300
1399
1400
1679
2300
OutputDivision 4
Division 4
Division 4
Division 4
Division 3
Division 2
Division 1

Note

For test cases 1−4, the corresponding ratings are −789, 1299, 1300, 1399, so all of them are in division 4.

For the fifth test case, the corresponding rating is 1400, so it is in division 3.

For the sixth test case, the corresponding rating is 1679, so it is in division 2.

For the seventh test case, the corresponding rating is 2300, so it is in division 1.


Solution

In this problem, we can easily solve it using if-else statements. Case-when is not suitable for this problem because it’s more appropriate for evaluating single values rather than comparing ranges.

C# Solution

Solution1

int t = int.Parse(Console.ReadLine());
int rating = 0;

for(int i=0; i<t; i++){
    rating = int.Parse(Console.ReadLine());

    if(rating>=1900){
        Console.WriteLine("Division 1");
    }
    else if(rating>=1600){
        Console.WriteLine("Division 2");
    }
    else if(rating>=1400){
        Console.WriteLine("Division 3");
    }
    else{
        Console.WriteLine("Division 4");
    }
}

Conclusion

🧡If my solution helps, that is my honor!

🧡You can support me by sharing my posts, thanks you~~

✅If you got any problem about the explanation or you need other programming language solution, please feel free to let me know !!

The problem link : Problem – 1669A – Codeforces

Random Codeforces Posts

Leave a Reply

Your email address will not be published. Required fields are marked *