Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
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
Tags
more
Archives
Today
Total
관리 메뉴

xcc1

백준 단계별 풀이 6단계 (파이썬) 본문

백준

백준 단계별 풀이 6단계 (파이썬)

xcc1 2021. 9. 2. 22:49
  • 15596번 정답
def solve(a: list):
    
    total = sum(a)
    
    return total

 

 

 

  • 4673번 정답
def d(n):
    num = n 
    total = 0
    list_n = list(str(n))
    list_int = []
    for i in list_n:
        list_int.append(int(i))
    total = num + sum(list_int)
    return total

list_self= []
for n in range(1,10001):
    k = d(n)
    list_self.append(k)

for m in range(1,10001):
    if m in list_self:
        pass
    else:
        print(m)

어려웠다..... 함수에 반복되는 작은 조각을 넣어야하는 것인데 크게 생각하니 어려웠다.

 

 

 

  • 1065번 정답
def h(i):
    list_n = list(str(i))
    list_int = []
    for i in list_n:
        list_int.append(int(i))
    
    return list_int

           

N = int(input())
cnt = 0

for i in range(1,N+1):
    li = h(i)
    n = int(len(li))
    if n > 1 :
        d = (li[-1] - li[0])/(n-1)
    else:
        d = 0

    total = (li[0]*2 + (n - 1)*d)*n/2
    if sum(li) == total:
        cnt += 1
    else:
        pass
print(cnt)

다른 분들 답 보니까 정말 슬프다... 

2자리 수까지는 모두 한수인 것만 알았더라면 정말 쉬웠을 문제...!! 

def h(i):
    cnt = 0
    for n in range(1,i+1):
        a = list(map(int, str(i)))
        if n < 100:
            cnt += 1
        elif a[1] - a[0] == a[2] - a[1]:
            cnt += 1
    
    return cnt

i = int(input())
print(h(i))

이렇게 간단하게 풀 것을....ㅠㅠ

 

 

 

'백준' 카테고리의 다른 글

백준 1193번  (0) 2021.10.27
백준 문제별풀이 7단계(파이썬)  (0) 2021.09.04
백준 단계별 풀이 5단계 (파이썬)  (0) 2021.08.31
백준 단계별 풀이 4단계 (파이썬)  (0) 2021.08.27
백준 단계별 풀이 3단계(파이썬)  (2) 2021.08.26