관리 메뉴

Silver Library (Archived)

Baekjoon algorithm - 10430 , python (map) 본문

F2. Problem & Solving/Solving

Baekjoon algorithm - 10430 , python (map)

Ayin Kim 2021. 2. 15. 23:02
반응형

Use 'map' to its initial list.

This allows programmer to let list acts multiple value aggregately.

 

As long as I know how map works out, I can finally achieve the simplicity (from refactoring process)

 

Error 1.

a,b,c = input().split()
a = int(a)
b = int(b)
c = int(c)
print((A+B)%C, ((A%C) + (B%C))%C, (A×B)%C, ((A%C) × (B%C))%C)

Result = Runtime error (NameError)

 

Note.

I guess this means 'as long as I wish to perform them all simultaneously, I have to use 'map'.

 

Check 1.

a,b,c = input().split()
a = int(a)
b = int(b)
c = int(c)
print((A+B)%C)
print((A%C) + (B%C))%C
print((A*B)%C)
print(((A%C) * (B%C))%C)

 

Note.

Yeah, definitely not. And messy.

 

Solution.

A,B,C = map(int,input().split())
print((A+B)%C, ((A%C) + (B%C))%C, (A*B)%C, ((A%C) * (B%C))%C, sep='\n')

 

dojang.io/mod/page/view.php?id=2286

 

파이썬 코딩 도장: 22.6 리스트에 map 사용하기

이번에는 리스트에 map을 사용해보겠습니다. map은 리스트의 요소를 지정된 함수로 처리해주는 함수입니다(map은 원본 리스트를 변경하지 않고 새 리스트를 생성합니다). list(map(함수, 리스트)) tupl

dojang.io

www.daleseo.com/python-map/

 

파이썬 map 내장 함수 사용법 (feat. List Comprehension)

Engineering Blog by Dale Seo

www.daleseo.com

 

 

백준 10430번 [파이썬 알고리즘] 나머지

[Python] 백준 알고리즘 온라인 저지 10430번 : 나머지 Python3 코드 A,B,C = map(int,input().split()) print((A+B)%C, ((A%C)+(B%C))%C, (A*B)%C, ((A%C)*(B%C))%C, sep='\n') # sep='\n'로 줄바꿈 Python3..

ooyoung.tistory.com

www.educba.com/python-nameerror/

 

Python NameError | How NameError Works in Python with Examples

Guide to Python NameError. Here we discuss the introduction, how NameError works? and avoiding NameErrors in python respectively.

www.educba.com

 

'F2. Problem & Solving > Solving' 카테고리의 다른 글

[JS] Day 1 : let and const  (0) 2021.06.11
Plan of learning the algorithm  (0) 2021.05.01
baekjoon algorithm - 10869  (0) 2021.02.15
Baekjoon algorithm - 1008, python  (0) 2021.02.15
Baekjoon - problem 1001, Python  (0) 2021.02.15