코딩테스트/SW Expert Academy

SWEA D1(difficult) 11~20 Python

1son 2023. 10. 16. 10:06

2043. 서랍의 비밀번호

p,k = map(int,input().split())

print(p-k+1)

 

 

2029. 몫과 나머지 출력하기

t = int(input())
for tc in range(1,t+1):
    a,b = map(int,input().split())
    share = a//b
    remain = a%b
    print(f'#{tc} {share} {remain}')

 

2027. 대각선 출력하기

for i in range(5):
    str = ''
    for j in range(5):
        if i==j:
            str+='#'
        else:
            str+='+'
    print(str)

 

2025. N줄덧셈

n = int(input())
result=0
for i in range(1,n+1):
    result+=i
print(result)

 

1938. 아주 간단한 계산기

a,b = map(int,input().split())

hap=a+b
minus=a-b
multiple=a*b
divide=a//b
print(str(hap)+'\n'+str(minus)+'\n'
      +str(multiple)+'\n'+str(divide))

 

1933. 간단한 N 의 약수

n=int(input())
lst = []
for i in range(1,n+1):
    if n%i==0:
       lst.append(i)
print(*lst)

*리스트 원소들을 한줄로 출력하려고 할 때 * 앞에 붙여주면 됨

* print(*lst)는 리스트 lst의 모든 요소를 한 줄로 출력합니다

 

 

1936. 1대1 가위바위보

a,b = map(int,input().split())

if a>b:
    print('A')
else:
    print('B')

 

2019. 더블더블

n=int(input())
value=1
lst = [1]
for i in range(n):
    value*=2
    lst.append(value)

print(*lst)

 

1545. 거꾸로 출력해 보아요

n = int(input())
lst = []
for i in range(n,-1,-1):
    lst.append(i)
print(*lst)

 

 

D1(difficult) 끝! 이제 D2 푼당