Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- Flutter
- 라라벨
- 플러터
- 뷰
- 99클럽
- 오블완
- 개발자취업
- DP
- Python
- til
- ML
- Laravel
- 개발자 취업
- 코딩테스트준비
- 코테
- react
- 파이썬 코테
- 파이썬
- c++ 코테
- 알고리즘
- C++
- 티스토리챌린지
- 백준
- 항해99
- flutter getx
- 코딩테스트 준비
- 안드로이드
- vue
- 코테 파이썬
- 코딩테스트
Archives
- Today
- Total
잡다로그
[Python/코테] 백준 2577번 숫자의 개수 본문
2577 숫자의 개수
문제 및 조건 설명: https://www.acmicpc.net/problem/2577


a = int(input())
b = int(input())
c = int(input())
result = [0] * 10
multiple = a * b * c
for i in list(str(multiple)):
result[int(i)] += 1
for i in result:
print(i)
나다어
- 특정 배열/범위를 순회하며 검색해야 하는 경우, 인덱스를 적극 활용하자.
- 파이썬의
str()함수는 정수를 문자열로 바꿔주는 연산이다. input()은 한 줄의 입력값을 받는 함수이다.
같은 로직이지만, 변수를 더 간단화한 풀이로는 아래와 같이 쓸 수 있다.
a = int(input())
b = int(input())
c = int(input())
d = a*b*c
d = str(d)
for i in range(10):
print(d.count(str(i)))
출처: https://www.acmicpc.net/source/53975405
혹은 더 간단하게 아래와 같이 쓸 수 있다.
prod = int(input())*int(input())*int(input())
for i in range(10):
print(str(prod).count(str(i)))
'Algorithm' 카테고리의 다른 글
| [C++/코테] 스택(Stack) 기초 (0) | 2023.11.08 |
|---|---|
| [Python/코테] 백준 10828 스택 (0) | 2023.11.08 |
| [Python/코테] 백준 28431 양말 짝 맞추기 (0) | 2023.11.08 |
| [Python/코테] 백준 2480번 주사위 세 개 (0) | 2023.11.08 |
| [Python/코테] 백준 2445번 별 찍기 (0) | 2023.11.08 |
Comments