[SWEA] 1926 간단한 369 게임

Time Lapse :5min 0sec

1926.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>

using namespace std;
void solution(int n) {
bool flag = false;
int N = n;
do {
if (N % 10 == 3 || N % 10 == 6 || N % 10 == 9) {
cout << "-";
flag = true;
}
N /= 10;
} while (N);
if (!flag) {
cout << n;
return;
}
}
int main(int argc, char** argv)
{
int test_case;
int T;
cin>>T;
for(test_case = 1; test_case < T; ++test_case)
{
solution(test_case);
cout << " ";
}
solution(T);
return 0;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/1926/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.