Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6
[CR] 10월 3주차#102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
[CR] 10월 3주차 #102
Changes from all commits
e275b3a8be0420834c3849ed563eed1d4e0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # https://www.acmicpc.net/board/view/73355 | ||
| from itertools import product | ||
| from sys import stdin | ||
| input = stdin.readline | ||
| # 현재 100번에서 시작 | ||
| # 먼저 제일 가까운 숫자를 찾아야 함 | ||
| def main(): | ||
| channel_num = int(input()) | ||
| broken = int(input()) | ||
| length = len(str(channel_num)) | ||
| if broken == 0: | ||
| print(min(length, abs(channel_num - 100))) | ||
| else: | ||
| # 일단 answer에 100번과의 차이를 저장 | ||
| answer = abs(channel_num - 100) if channel_num != 100 else 0 | ||
| broken_nums = set(input().split()) | ||
| nums = set(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]) | ||
| normal_nums = nums - broken_nums | ||
| # 가능한 조합 중 원하는 채널보다 하나 작은 개수, 같은 개수, 하나 많은 개수의 길이인 경우 구하기 | ||
| possible_nums = [] | ||
| if length == 1: | ||
| for x in range(length, length + 2): | ||
| possible_nums.extend(product(normal_nums, repeat = x)) | ||
| else: | ||
| for x in range(length - 1, length + 2): | ||
| possible_nums.extend(product(normal_nums, repeat = x)) | ||
| for y in possible_nums: | ||
| num = int("".join(y)) | ||
| if abs(channel_num - num) + len(y) < answer: | ||
| answer = abs(channel_num - num) + len(y) | ||
| print(answer) | ||
| main() | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 쉽게 작성해주셔서 잘 읽을 수 있었습니다. :) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from sys import stdin | ||
| input = stdin.readline | ||
| T = int(input()) | ||
| for _ in range(T): | ||
| clothes = int(input()) | ||
| cloth_dict = {} | ||
| for _ in range(clothes): | ||
| cloth, type = input().split() | ||
| if type in cloth_dict: | ||
| cloth_dict[type] += 1 | ||
| else: | ||
| cloth_dict[type] = 1 | ||
| # 해당 종류를 입을지 안입을지 모든 경우의 수 곱하기 | ||
| answer = 1 | ||
| for type in cloth_dict: | ||
| answer *= cloth_dict[type] + 1 | ||
| # 알몸이 되는 경우 빼기 | ||
| print(answer - 1) | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 풀이가 동일해요! 그래서 술술 읽혔습니다. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extend 신기하네요..! 파이썬 대단해..