말랑한 하루

[SW Expert Academy] 1288 새로운 불면증 치료법 [C++] 본문

문제풀이/SWexpert Academy

[SW Expert Academy] 1288 새로운 불면증 치료법 [C++]

지수는말랑이 2021. 1. 20. 01:13
반응형

[ 핵심풀이 ]

[ 핵심소스 ]

[ C++ ]

#include <iostream>
#include <string>
#include <string.h>
#pragma warning(disable:4996)

using namespace std;

#define endl "\n"
#define MAX 10

bool sheep[MAX];
int main() {
    int tc;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        memset(sheep, 0, sizeof sheep);
        int temp, cnt = 1, view=0;
        cin >> temp;
        while (true) {
            if (view == 10) break;
            string sleep = to_string(temp * cnt++);
            for (int i = 0; i < sleep.length(); i++) {
                if (!sheep[sleep[i] - '0']) {
                    view++;
                    sheep[sleep[i] - '0'] = true;
                }
            }
        }
        cout << "#" << t << " " << temp*(cnt-1) << endl;
    }
}
반응형
Comments