목록수학 (11)
동캄의 코딩도장
https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #프로그래머스 level2 마법의 엘리베이터 def solution(storey): answer = 0 storey=str(storey) list_=list(map(int,storey)) for i in range(len(list_)-1,0,-1): if list_[i]>5: # 현재 숫자가 5보다 크면 올림 answer+=10-list_[i] list_[i-1]+=1 elif list_[i]=..
https://www.acmicpc.net/problem/1654 1654번: 랜선 자르기 첫째 줄에는 오영식이 이미 가지고 있는 랜선의 개수 K, 그리고 필요한 랜선의 개수 N이 입력된다. K는 1이상 10,000이하의 정수이고, N은 1이상 1,000,000이하의 정수이다. 그리고 항상 K ≦ N 이다. 그 www.acmicpc.net 처음 접근은 평균을 내고, 평균부터 시작해서 1씩 빼면서 N개를 만들 수 있는지 탐색하였다. 시간 초과가 발생하였다. #백준 1654 랜선 자르기 시간초과 코드 K,N=map(int,input().split()) lans=[] lans_sum=0 lans_avg=0 temp=0 for _ in range(K): lan=int(input()) lans_sum+=lan l..
https://school.programmers.co.kr/learn/courses/30/lessons/120875 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr # 프로그래머스 평행 def solution(dots): answer = 0 x1, y1 = dots[0] x2, y2 = dots[1] x3, y3 = dots[2] x4, y4 = dots[3] if ((y2-y1)/(x2-x1) == (y4-y3)/(x4-x3)): answer = 1 elif (((y2-y3)/(x2-x3) == (y4-y1)/(x4-x1))): answer = 1 eli..
https://www.acmicpc.net/problem/6588 6588번: 골드바흐의 추측 각 테스트 케이스에 대해서, n = a + b 형태로 출력한다. 이때, a와 b는 홀수 소수이다. 숫자와 연산자는 공백 하나로 구분되어져 있다. 만약, n을 만들 수 있는 방법이 여러 가지라면, b-a가 가장 큰 www.acmicpc.net # 백준 6588 골드바흐의 추측 import sys input = sys.stdin.readline def isPrime(num): i = 3 while i**2 n2: break else: check = isPrime(n1)+isPrime(n2) if check == 2: break if check != 2: print("Goldbach's conjecture is wr..
https://www.acmicpc.net/problem/4375 4375번: 1 2와 5로 나누어 떨어지지 않는 정수 n(1 ≤ n ≤ 10000)가 주어졌을 때, 1로만 이루어진 n의 배수를 찾는 프로그램을 작성하시오. www.acmicpc.net # 백준 4375 import sys input = sys.stdin.readline while True: ans = 1 a = 1 s = input().rstrip() if s: num = int(s) while True: if a % num == 0: print(ans) break else: a *= 10 a += 1 ans += 1 else: break
https://www.acmicpc.net/problem/2853 2853번: 배 해빈이는 배가 한 척이라도 올까 말까 한 작은 항구 마을에 산다. 그런데 어느 날, 마을을 방문한 적이 있는 모든 배가 한꺼번에 마을을 방문한 날이 있었다. 해빈이는 이 날을 기념해 1일로 센 www.acmicpc.net #백준 2853 import sys n=int(sys.stdin.readline()) lst=[] for i in range(n): lst.append(int(sys.stdin.readline())) checked=[0]*(n) ans=0 for i in range(1,n): if checked[i]==0: d=lst[i]-lst[0] ans+=1 for j in range(i+1,n): if (lst[j..