๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ๐Ÿฃ: ๐’œ๐“๐‘”๐‘œ๐“‡๐’พ๐“‰๐’ฝ๐“‚/์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ํ’€์ด

BOJ5671 : ํ˜ธํ…” ๋ฐฉ ๋ฒˆํ˜ธ (Silver 5)

#include <iostream>
using namespace std;

int main()
{
    while (1)
    {
        int N, M;
        int count = 0;
        cin >> N >> M;
        if (cin.eof())
            break;
        for (int i = N; i <= M; i++)
        {
            int a = i / 1000;
            int b = i / 100 % 10;
            int c = i / 10 % 10;
            int d = i % 10;
            if (a == 0 && b == 0 && c == 0)
                count++;
            else if (a == 0 && b == 0)
            {
                if (c != d)
                    count++;
            }
            else if (a == 0)
            {
                if (b != c && c != d && d != b)
                    count++;
            }
            else
            {
                if (!(a == b || b == c || c == d || a == c || a == d || b == d))
                    count++;
            }
        }
        cout << count << "\n";
    }
}

๊ทธ๋ƒฅ ํ•ด๋‹น ๋ฒ”์œ„ ์•ˆ์—์„œ ๊ฐ ์ž๋ฆฌ ์ˆซ์ž๊ฐ€ ๋ชจ๋‘ ๋‹ค๋ฅธ ๊ฒฝ์šฐ count++ ํ•ด์ฃผ๋ฉด ๋จ.

๋‚œ ์˜คํžˆ๋ ค eof์—์„œ ์ด๋Ÿฐ ๊ฒฝ์šฐ ์ฒ˜์Œ ๋ด์„œ ์–ธ์ œ while์„ ๋๋‚ด์•ผ ํ•˜๋Š”์ง€๊ฐ€ ๋” ์• ๋จน์—ˆ์—ˆ๋”ฐ..=_=;