[백준]10430 Remainder

차보경·2022년 8월 27일
0

백준

목록 보기
3/20
post-thumbnail

문제# map 함수 이용

def add_one(n):
return n + 1

result2 = list(map(add_one, myList)) # map반환을 list 로 변환
print(f'result2 : {result2}')
출처: https://blockdmask.tistory.com/531 [개발자 지망생:티스토리]

로직 정리

  1. space 기준으로 받은 값을 숫자형태로 변경
  2. 순서에 맞춰 print

알아야 할 것

  • 연속적인(list) 값들 한번에 type 변환(이번엔 int형태로)
    • map(function, iterable) => map(적용시킬 함수, 적용할 값들)

    • map함수 안 function의 동작은 두 번째 인자로 들어온 반복 가능한 자료형(리스트나 튜플)을 첫 번째 인자로 들어온 함수에 하나씩 집어넣어서 수행하는 함수

    • 예시

      # map 함수 이용
      def add_one(n):
      return n + 1
      
      # map 함수를 list화 
      result2 = list(map(add_one, myList))  
      print(f'result2 : {result2}')
    • 출처

작성 코드

def reaminder(A,B,C):
    print((A+B)%C)
    print(((A%C) + (B%C))%C)
    print((A*B)%C)
    print(((A%C) * (B%C))%C)

A,B,C = map(int,input().split(" "))
reaminder(A,B,C)

복기

  • 1차 작성 (틀림)
def reaminder(A,B,C):
    print((A+B)%C)
    print(((A%C) + (B%C))%C)
    print((A*B)%C)
    print(((A%C) * (B%C))%C)

A,B,C = int(input().split(" "))
reaminder(A,B,C)

TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

이 오류 이후 map 함수 찾아서 적용함

메모리시간코드 길이
3084068171
profile
차보의 Data Engineer 도전기♥ (근데 기록을 곁들인)

0개의 댓글