Python

개인공부/Programmers

[Python] x만큼 간격이 있는 n개의 숫자

x만큼 간격이 있는 n개의 숫자 ( https://programmers.co.kr/learn/courses/30/lessons/12954 ) 스스로 풀어볼 때 try: def solution(x, n): answer = [x] * n for i in range(1, n) : answer[i] = x*i+x return answer x, n = map(int, input().split(" ")) print(solution(x, n)) except EOFError: print(end="") 채점 후 다른 코드를 참고하여 다시 수정할 때 try: def solution(x, n): return [x * i for i in range(1, n+1)] x, n = map(int, input().split(" ")..

개인공부/Baekjoon Online Judge

[Python] 3052번

3052번 - 나머지 ( https://www.acmicpc.net/problem/3052 ) 주석 O # num에 숫자를 10번 입력 받는다. num = [ int(input()) for _ in range(10) ] # 빈 배열을 만든다. result = [] # 반복문을 10번 실행한다. for i in range(10) : # 빈 배열 result에 num에 입력받은 숫자들을 42로 나눈 나머지 값을 넣는다. result.append(num[i] % 42) # count 변수에 result 배열에서 중복을 제거하고 남은 # 배열의 길이를 저장한다. count = len(set(result)) # count를 출력한다. print(count) 주석 X num = [ int(input()) for _..

개인공부/Baekjoon Online Judge

[Python] 2577번

2577번 - 숫자의 개수 ( https://www.acmicpc.net/problem/2577 ) 주석 O # 입력 a = int(input()) b = int(input()) c = int(input()) # a, b, c 를 곱한 값을 배열로 만들기 arr = list(str(a * b * c)) # 0~9 까지 반복 for i in range(10) : # 0~9 까지의 숫자가 몇개 있는지 string으로 변환하여 같은 문자 count print(arr.count(str(i))) 주석 X a = int(input()) b = int(input()) c = int(input()) arr = list(str(a * b * c)) for i in range(10) : print(arr.count(str..

개인공부/Baekjoon Online Judge

[Python] 2480번

2480번 - 주사위 세개 ( https://www.acmicpc.net/problem/2480 ) 주석 O one, two, three = map(int, input().split(" ")) if one == two == three : # 셋 다 같을 때 print(10000 + one * (1000)) elif one == two or one == three : # 두개만 같을 때 print(1000 + one * (100)) elif two == three : print(1000 + three * (100)) else : # 다 다를때 print(100 * max(one, two, three)) 주석 X one, two, three = map(int, input().split(" ")) if one..

H E E
'Python' 태그의 글 목록