목록코테 (95)
홍우진의 개발 일기장
문제 링크https://www.acmicpc.net/problem/1526풀이 코드n = int(input())for i in range(int(n),0,-1): cnt = 0 for j in str(i): if j == '4' or j == '7': cnt += 1 if len(str(i)) == cnt: print(i) break코드 해석 1씩 빼며 각 자릿수가 4 혹은 7로 이루어져 있나 확인한다.만약 이루어져있으면 cnt += 1을 하고,cnt가 수의 길이와 같을 경우 출력한다. 체감 난이도: ★☆☆☆☆간만에 문제 푸는 맛이 있는 문제ㅇ다.
문제 링크https://www.acmicpc.net/problem/10996풀이 코드n = int(input())for _ in range(n): print('* '* (n - n // 2)) # 홀수 print(' *'* (n // 2)) # 짝수코드 해석 오래간만에 별찍기를 해봤다. 체감 난이도: ★★☆☆☆
문제 링크https://www.acmicpc.net/problem/25757풀이 코드import sysn, k = sys.stdin.readline().split()people = set()for _ in range(int(n)): people.add(sys.stdin.readline().rstrip())if k == 'Y': print(len(people))elif k == 'F': print(len(people)//2)else: print(len(people)//3)코드 해석 set 으로 중복을 제거하여 값을 받고,게임에 맞게 나눠 출력하면 끝. 체감 난이도: ☆☆☆☆☆오래간만에 힐링되는 쉬운 문제다.
문제 링크https://www.acmicpc.net/problem/1057풀이 코드n, a, b = map(int, input().split())cnt = 0while a != b: a -= a // 2 b -= b // 2 cnt += 1print(cnt)코드 해석 토너먼트에서 무조건 승리한다면다음 라운드엔 현재 번호 // 2의 번호가 된다. 체감 난이도: ★★★☆☆점화식 찾기가 왜인지 모르겠는데 힘들었다.
문제 링크https://www.acmicpc.net/problem/2303풀이 코드n = int(input())score = []for _ in range(n): card = list(map(int,input().split())) top = 0 for i in range(5): for j in range(i + 1, 5): for m in range(j + 1, 5): dap = (card[i] + card[j] + card[m])%10 if dap >= top: top = dap score.append(top)for i in r..
문제 링크https://www.acmicpc.net/problem/1620풀이 코드import sysinput = sys.stdin.readlinen, m = map(int,input().split())pok = {} for i in range(n): pok[str(i+1)] = input().rstrip() # 포켓몬명을 딕셔너리로 받는다. 뒤의 .rstrip()은 \n을 지워준다.kop = {v:k for k,v in pok.items()} # vel:key 인 딕셔너리를 하나 더 만들어 시간복잡도를 줄인다.for i in range(m): moon = input().rstrip() if moon.isdigit(): # 문제가 int라면 print(p..
문제 링크https://www.acmicpc.net/problem/1406풀이 코드from sys import stdinleft = list(input())right = []for _ in range(int(input())): inp = list(stdin.readline().split()) if inp[0] == 'L' and left: right.append(left.pop()) elif inp[0] == 'D' and right: left.append(right.pop()) elif inp[0] == 'B' and left: left.pop() elif inp[0] == 'P': left.append(inp[1])dap =..
문제 링크https://www.acmicpc.net/problem/15655풀이 코드n, m = map(int,input().split())arr = sorted(list(map(int,input().split())))li = []def dfs(idx, cnt): if cnt == m: print(*li) for i in range(idx, n): idx += 1 li.append(arr[i]) dfs(idx, cnt + 1) li.pop()dfs(0,0)코드 해석 백트래킹 문제다.https://woojinhong.tistory.com/295 [백준] 10974번: 모든 순열 / 파이썬문제 링크https://www.acmic..