본문 바로가기
Algorithm/etc

[파이썬] 백준 - 8단계 입출력과 사칙연산

by 베짱이28호 2023. 4. 5.

백준 - 8단계 입출력과 사칙연산


달팽이는 올라가고 싶다 (2869)

A,B,V = map(int,input().split())
import math
if A>V :
print(1)
else :
print(math.ceil((V-A)/(A-B))+1)

벌집 (2292)

N = int(input())
temp = (N-2)/6
check_point,i = 0,0
while True:
if N==1:
print(1)
break
else:
check_point += i
i += 1
if check_point > temp:
print(i)
break

수열찾는문제


분수찾기 (1193)

X = int(input())
check_point,i = 1,1
while True:
if X == 1 :
print('1/1')
break
else :
check_point += i
i += 1
if check_point > X:
break
check_point = check_point-i
step = X-check_point
if X != 1:
if i%2 == 0: # 위에서 아래로
x,y = i-step,step
print(f'{x}/{y}')
else: # 아래서 위로
x,y = step,i-step
print(f'{x}/{y}')

 


세탁소 사장 동혁 (2720)

T = int(input())
temp = [25,10,5,1]
for j in range(T):
C = int(input())
for i in range(4):
count = C//temp[i]
C = C%temp[i]
print(count,end=' ')

중앙 이동 알고리즘 (2903)

N = int(input())
l=2
for i in range(N):
l = 2*l-1
print(l**2)

수열 찾기


진법 변환 (2745)

N,B = input().split()
N = str(N)
B = int(B)
temp='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
answer = 0
for i in range(len(N)):
answer += temp.index(N[i])*(B**(len(N)-(i+1)))
print(answer)

 


진법 변환 2 (11005)

N,B = map(int,input().split())
temp='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
answer = []
while True:
answer.append(N%B)
N = N//B
if N<B:
if N != 0:
answer.append(N)
break
else:
break
for i in range(len(answer)):
answer[i] = temp[answer[i]]
answer = ''.join(answer)
print(answer[::-1])

큰 수 A+B (10757)

A,B = map(int,input().split())
print(A+B)

백준 처음해봐서 input 안에 문구 넣었다가 3번이나 틀림 맞왜틀?

 


 

댓글