# Link

https://www.acmicpc.net/problem/5671

 

5671번: 호텔 방 번호

선영이는 집 호수에 반복되는 숫자가 있는 경우에는 그 집에 사는 사람에게 불운이 찾아온다고 믿는다. 따라서, 선영이는 838호나 1004호와 같이 한 숫자가 두 번 이상 들어있는 집에는 절대 살지

www.acmicpc.net

 

 

# Code - C++

//
//  BOJ
//  ver.C++
//
//  Created by GGlifer
//
//  Open Source

#include <iostream>
#include <set>

using namespace std;

#define endl '\n'
#define len(x) (int)(x).length()
#define size(x) (int)(x).size()
#define str(x) to_string(x)
#define error logic_error("line " + str(__LINE__))

// Set up : Definitions
/* None */

// Set up : Global Variables
/* None */

// Set up : Functions Declaration
/* None */


int main()
{
    // Set up : I/O
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // Set up : Input
    int N, M;
    while (cin >> N >> M) {

        // Process
        int ans = 0;
        for (int i=N; i<=M; i++) {
            string s = str(i);
            if (len(s) == size(set(s.begin(), s.end()))) {
                ans++;
            }
        }

        // Control : Output
        cout << ans << endl;
    }
}

// Helper Functions
/* None */

 

 

지적, 조언, 첨언 모두 환영합니다!!!

+ Recent posts