[파이썬][백준 10886번] 0 = not cute / 1 = cute
1. 문제Permalink
[Bronze III] 0 = not cute / 1 = cute - 10886Permalink
성능 요약Permalink
메모리: 30840 KB, 시간: 68 ms
분류Permalink
사칙연산(arithmetic), 구현(implementation), 수학(math)
출처: 백준, https://https://www.acmicpc.net/
2. 해결방법 시간복잡도Permalink
- 단순 코딩 O(N)
3. 문제 해결 및 코드Permalink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
T = int(sys.stdin.readline()) | |
result = [] | |
for _ in range(T): | |
result.append(str(input())) | |
if result.count("0") > result.count("1"): | |
print("Junhee is not cute!") | |
else: | |
print("Junhee is cute!") |
-
주석을 참고하면서 이해를 돕습니다.Permalink
4. 알고리즘 및 해설Permalink
- 준희의 귀여움을 판단하는 문제로 굉장히 중요하다.
- 반복문을 통해 해당 결과값에 문자열을 삽입한다.
- 이후 count() 함수를 통해 리스트내의 0과 1의 개수를 if문을 통해 경우에 따라 출력한다.
5. 짚고 넘어가기Permalink
- count() 함수를 통해 리스트의 문자열을 세는 것이 중요하다.