Development Project

[ Baekjoon - 단계별로 풀어보기(05/28) ] - 5단계 : 함수 본문

CodingTest/Baekjoon

[ Baekjoon - 단계별로 풀어보기(05/28) ] - 5단계 : 함수

나를 위한 시간 2022. 5. 29. 03:24
  • 15596 : 정수 N개의 합
def solve(a):
    ans = 0
    for i in a:
        ans += int(i)
    return ans
#
def solve(a):
    return(sum(a))
#
solve=sum

 

  • 4673 : 셀프 넘버
def fun():
    m = []
    for i in range(1,10000):
        k = list(str(i))
        for j in k:
            i += int(j)
        m.append(i)
        
    for p in range(1,10000):
        if p not in m:
            print(p)
fun()

 

  • 1065 : 한수
def num(n):
    ans = 0
    for i in range (1, n+1): 
        if i<100: 
            ans += 1
        else:
            strN = str(i)
            if int(strN[0]) + int(strN[2]) == (int(strN[1]))*2:
                ans += 1
    return ans
print(num(int(input())))
Comments