알고리즘

[알고리즘] 백준 1871 - 좋은 자동차 번호판 (C++)

blueberrysoda 2025. 1. 5. 23:29

[문제 링크] : https://www.acmicpc.net/problem/1871

#include <iostream>
using namespace std;

int main(){
    int T;
    string S;
    cin >> T;

    while(T--){
        cin >> S;
        int Ans = abs(((S[0] - 'A') * 26 * 26 + (S[1] - 'A') * 26 + (S[2] - 'A')) - ((S[4] - '0') * 1000 + (S[5] - '0') * 100 + (S[6] - '0') * 10 + (S[7] - '0')));
        if(Ans <= 100){
            cout << "nice\n";
        }
        else{
            cout << "not nice\n";
        }
    }
    return 0;
}