"SWEA 1288 새로운 불면증 치료법"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 3명의 중간 판 9개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;SWEA 1940 가랏! RC카!
;SSWEA 1288 새로운 불면증 치료법
이거완전 sheep세기네(댓글 중에)


{{SWEA 헤더}}
{{SWEA 헤더}}
7번째 줄: 8번째 줄:


==C++==
==C++==
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
</source>
#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
int test_case;
int T;
cin >> T;
for (test_case = 1; test_case <= T; ++test_case) {
int arr[10] = { 0 };
int answer = 0;
int input;
scanf("%d", &input);
int N = input;
for (int i = 0; ; i++) {
int temp = N;
while (N != 0) {
arr[N % 10] = 1;
N /= 10;
}
int count = 0;
for (int j = 0; j<10; j++) {
if (arr[j] == 1) count++;
}
if (count == 10) {
answer = temp;
break;
}
N = input * i;
}
printf("#%d %d\n", test_case, answer);
}
return 0;
}
</syntaxhighlight>


==Java==
==Java==
<source lang='java'>
<syntaxhighlight lang='java'>
import java.util.*;
import java.util.*;
class Solution {
public class Solution {
public static void main(String[] args) {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Scanner sc = new Scanner(System.in);
19번째 줄: 53번째 줄:
T=sc.nextInt();
T=sc.nextInt();


int N, i, cur, q, temp;
int N, i, cur, temp, q;
Set<Integer> seen = new HashSet<Integer>();
Set<Integer> seen = new HashSet<Integer>();


38번째 줄: 72번째 줄:
}
}
}
}
</source>
</syntaxhighlight>
 
==Python==
<syntaxhighlight lang='python'>
T = int(input())
for x in range(1, T+1):
    N = int(input())
    count = 0
   
    zero_to_nine = [str(i) for i in range(10)]
    while zero_to_nine:
        count += 1
        room = N * count
        room = str(room)
 
        for c in room:
            if c in zero_to_nine:
                zero_to_nine.remove(c)
 
    print('#{} {}'.format(x, room))
 
# github.com/wansang93/Algorithm
</syntaxhighlight>

2021년 7월 31일 (토) 10:54 기준 최신판

1 개요[ | ]

SSWEA 1288 새로운 불면증 치료법

이거완전 sheep세기네(댓글 중에)

SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 2-3

2 C++[ | ]

#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
	int test_case;
	int T;
	cin >> T;
	for (test_case = 1; test_case <= T; ++test_case) {
		int arr[10] = { 0 };
		int answer = 0;
		int input;
		scanf("%d", &input);
		int N = input;
		for (int i = 0; ; i++) {
			int temp = N;
			while (N != 0) {
				arr[N % 10] = 1;
				N /= 10;
			}
			int count = 0;
			for (int j = 0; j<10; j++) {
				if (arr[j] == 1) count++;
			}
			if (count == 10) {
				answer = temp;
				break;
			}
			N = input * i;
		}
		printf("#%d %d\n", test_case, answer);
	}
	return 0;
}

3 Java[ | ]

import java.util.*;
public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T;
		T=sc.nextInt();

		int N, i, cur, temp, q;
		Set<Integer> seen = new HashSet<Integer>();

		for(int test_case = 1; test_case <= T; test_case++) {
			N = sc.nextInt();
			seen.clear();
			for(i=1; ; i++) {
				cur = N*i;
				for(temp=cur; temp>0; temp/=10) {
					q = temp%10;
					seen.add(q);
				}
				if(seen.size()>9) break;
			}
			System.out.format("#%d %d\n", test_case, cur);
		}
		sc.close();
	}
}

4 Python[ | ]

T = int(input())
for x in range(1, T+1):
    N = int(input())
    count = 0
    
    zero_to_nine = [str(i) for i in range(10)]
    while zero_to_nine:
        count += 1
        room = N * count
        room = str(room)

        for c in room:
            if c in zero_to_nine:
                zero_to_nine.remove(c)

    print('#{} {}'.format(x, room))

# github.com/wansang93/Algorithm
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}