아이공의 AI 공부 도전기

[Baekjoon] 1075번 : 나누기 (Python, 수학)

 

     

 

 

https://www.acmicpc.net/problem/1075

 

1075번: 나누기

첫째 줄에 N, 둘째 줄에 F가 주어진다. N은 100보다 크거나 같고, 2,000,000,000보다 작거나 같은 자연수이다. F는 100보다 작거나 같은 자연수이다.

www.acmicpc.net

코드 링크

https://github.com/stellaluminary/Baekjoon

 

GitHub - stellaluminary/Baekjoon

Contribute to stellaluminary/Baekjoon development by creating an account on GitHub.

github.com

 

Python

 

방법 1 - 메모리 30840KB / 시간 92ms / 코드 길이 147B

 

n = int(input())
f = int(input())
for i in range(n//100*100, (n//100+1)*100):
    if i % f == 0:
        print((str(i%100)).zfill(2))
        break

 

방법 2 - 메모리 30840KB / 시간 76ms / 코드 길이 125B

n = input()
f = int(input())
nw = int(n[:-2]+'00')
while 1:
    if nw % f == 0:
        break
    nw += 1
print(str(nw)[-2:])

 

 

방법 3 - 메모리 30840KB / 시간 68ms / 코드 길이 B

n = int(input())
f = int(input())
n -= n%100
res = f - n%f
if res == f:
    res = 0
print('%02d' %res)

 

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading