[UVa #621] Secret Research

tolelom·2022년 7월 6일
0

UVa

목록 보기
17/20

문제 설명

문제 링크
주어진 숫자를 특정 패턴에 부합하는지 판별하는 문제

알고리즘

주어진 조건에 맞게 분기해주면 된다.

코드

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1000000000

int t;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    for (int tc = 1; tc <= t; tc++){
        string s;
        cin >> s;

        int l = s.length();

        if (s == "1" || s == "4" || s == "78")
            cout << "+" << '\n';
        else if (l >= 3 && s.substr(l-2, 2) == "35")
            cout << "-" << '\n';
        else if (l >= 3 && s[0] =='9' && s[l-1] == '4')
            cout << "*" << '\n';
        else if (l >= 4 && s.substr(0, 3) == "190")
            cout << "?" << '\n';
    }
}
profile
이것 저것 작성하는 기술 블로그

0개의 댓글