백준 문제집 리스트 중 automata님의 Python 배우기 (1~50) 문제집의 풀이이다 (간단한 문제들은 설명이 없을 수 있음..)

https://www.acmicpc.net/workbook/view/459

 

문제집: Python 배우기 (1~50) (automata)

 

www.acmicpc.net

 

⭐️ 전에 푼거 아직 옮기는중..

 

2557 - Hello World

print('Hello World!')

 

1000 - A+B

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

if 0 < a and b < 10:
    print(a + b)

 

10998 - A×B

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

if 0 < a and b < 10:
    print(a*b)

 

1001 - A-B

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

if 0 < a and b < 10:
    print(a - b)

 

1008 - A/B

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

if 0 < a and b < 10:
    print(a / b)

 

10869 - 사칙연산

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

if 1 <= a and b <= 10000:
    print(a + b)
    print(a - b)
    print(a * b)
    print(a // b)
    print(a % b)

 

10430 - 나머지

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

if 2<=a<=100000 and 2<=b<=100000 and 2<=c<=100000:
    print((a+b)%c)
    print(((a%c)+(b%c))%c)
    print((a*b)%c)
    print(((a%c)*(b%c))%c)

 

2558 - A+B - 2

a = int(input())
b = int(input())
print(a + b)

 

2588 - 곱셈

fir = int(input())
sec = input()

print(fir * int(sec[2]))
print(fir * int(sec[1]))
print(fir * int(sec[0]))
print(fir * int(sec))

 

3046 - R2

R1, S = map(int, input().split())

R2 = S*2 - R1
print(R2)

 

2163 - 초콜릿 자르기

n, m = map(int, input().split())
choco = n*m
print(choco//1-1)

 

11021 - A+B - 7

t = int(input())

for i in range(t):
    a, b = map(int, input().split())
    if 0<a and b<10:
        print('Case #{}: {}' .format(i+1, a+b))

 

11022 - A+B - 8

t = int(input())

for i in range(t):
    a, b = map(int, input().split())
    if 0<a and b<10:
        print('Case #{}: {} + {} = {}'.format(i+1, a, b, a+b))

 

10699 - 오늘 날짜

print("2023-02-22")

 

7287 - 등록

71
t1mmyt1m

 

2525 - 오븐 시계

h, m = map(int, input().split())
c = int(input())

#if 0<=h<=23 and 0<=m<=59 and 0<=c<=1000:

a, b = (h+((m+c)//60), (m+c))
if b>59:
    print((h+((m+c)//60))%24, b%60)
elif b<59:
    print(a, b)
else:
    print(a, b%60)

 

2530 - 인공지능 시계

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

c += i%60
i = i//60
if c >= 60:
    c -= 60
    b += 1

b += i%60
i = i//60
if b >= 60:
    b -= 60
    a += 1

a += i%24
if a >= 24:
    a -= 24


print(a, b, c)

 

2914 - 저작권

a, j = map(int, input().split()) 
print(a * (j - 1) + 1)

 

5355 - 화성 수학

t = int(input())

for _ in range(t):
    n = list(map(str, input().split()))
    
    a = n[0]
    n.remove(a)
    a = float(a)

    for i in range(len(n)):

        if n[i] == '@':
            a *= 3
        elif n[i] == '%':
            a += 5
        elif n[i] == '#':
            a -= 7


    print("%0.2f"%a)

 

2675 - 문자열 반복

s = int(input())

for i in range(s):
    a , b = map(str, input().split())
    a = int(a)

    for j in range(len(b)):
        print(a*b[j], end='')
    print() #줄을 바꾸고 range(s)만큼 반복

 

2935 - 소음

a = int(input())
e = input()
b = int(input())

if e == '+':
    print(a + b)
elif e == '*':
    print(a * b)

 

9498 - 시험 성적

score = int(input())

if score >= 90:
    print("A")
elif 89>= score >= 80:
    print("B")
elif 79>= score >= 70:
    print("C")
elif 69>= score >= 60:
    print("D")
else:
    print("F")

 

10817 - 세 수

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

a.sort(reverse=False)
print(a[1])

 

11653 - 소인수분해

import math

n = int(input())
i = 2

while i <= math.sqrt(n):
    if n % i != 0:
        i += 1
    else:
        print(i)
        n //= i

if n > 1:
    print(n)

 

1789 - 수들의 합

s = int(input())
p = []
a = 1

while True:
    s -= a
    p.append(a)
    a += 1
    if s == 0:
        break
    elif s > 0:
        continue
    else:
        s += p[-1]
        if s in p:
            p.remove(s)
            s += s
            set(p) 
        break

print(len(p))

 

2753 - 윤년

a = int(input())

if 1<=a<=4000:
    if a%4==0 and a%100!=0 or a%400==0:
        print(1)
    else:
        print(0)

 

10039 - 평균 점수

a = []

for _ in range(5):
    a.append(int(input()))

for i in range(5):
    if a[i] < 40:
        a[i] = 40

print(sum(a) // 5)

 

1934 - 최소공배수

import math

def lcm(a, b):
    return a * b // math.gcd(a, b)

line = int(input())

for i in range(line):
    x, y = map(int, input().split())
    print(lcm(x, y))

 

2480 - 주사위 세개

t1, t2, t3 = list(map(int, input().split()))

if t1==t2==t3:
    print(10000 + t1*1000)
elif t1==t2 or t2==t3:
    print(1000 + t2*100)
elif t3==t1:
    print(1000 + t3*100)
else:
    print(max(t1, t2, t3)*100)

 

4101 - 크냐?

while True:
    a, b = list(map(int, input().split()))
    if a > b:
        print("Yes")
    elif a == 0 and b == 0: #
        break
    elif a < b or a == b:
        print("No")

 

10156 - 과자

k, n, m = map(int, input().split())

if k*n <= m:
    print(0)
else:
    print(k*n-m)

 

3009 - 네 번째 점

x, y = [], []

for i in range(3):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)


i = 0

if x[i] == x[i+1]:
    c = x[i+2]
elif x[i] == x[i+2]:
    c = x[i+1]
elif x[i+1] == x[i+2]:
    c = x[i]
else:
    c = x[i]

if y[i] == y[i+1]:
    d = y[i+2]
elif y[i] == y[i+2]:
    d = y[i+1]
elif y[i+1] == y[i+2]:
    d = y[i]
else:
    d = y[i]

print(c, d)

 

2476 - 주사위 게임

a = int(input())
b = []

for i in range(1, a+1):
    nums = list(map(int, input().split()))
    dup = {x for x in nums if nums.count(x) == 2}
    eup = {x for x in nums if nums.count(x) == 3}
    # 위 코드는 중복되는 숫자를 리스트에 추가하는 코드

    #if nums.count(x) > 1:
    #    for x in nums:
    #        dup.append(x)
    if dup:
        c = 1000+dup.pop()*100 #dup.pop()을 해주는 이유는 set에 있는 숫자인 중복되는 수를 int로 꺼내서 연산하기 위함
        #그냥 dup로 하면 TypeError: unsupported operand type(s) for *: 'set' and 'int' 에러뜸
    elif eup:
        c = 10000+eup.pop()*1000
    else:
        c = max(nums)*100
    b.append(c)

print(max(b))

 

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

 

6081

n = int(input(), 16)
for i in range(1, 16):
    print('%X'%n, '*%X'%i, '=%X'%(n*i), sep='')

6082

i = int(input())
for h in range(1, i+1):
    if h%10==3 or h%10==6 or h%10==9:
        print("X", end=' ')
    else:
        print(h, end=' ')

6083

r, g, b = map(int, input().split())
num = 0

for i in range(0, r):
    for j in range(0, g):
        for h in range(0, b):
            print(i, j, h)
            
            num+=1
print(num)

6084

h, b, c, s = map(int, input().split())
space = (h*b*c*s)/8/1024/1024

print(round(space, 1) ,"MB")

h, b, c, s = map(int, input().split())
space = (h*b*c*s)/8/1024/1024

print(format(space, ".1f"), "MB")

6085

#반올림이 아닌 소수점 2자리까지 표기하는거인듯
#전에 했던 코드처럼 입력했더니 0.00으로 나와야하는 값이 0.0으로 출력됨

w, h, b = map(int, input().split())
space = ((w*h*b)/8/1024/1024)

print(format(space, ".2f"), "MB")

6086

n = int(input())
s,c = 0,1

while True:
    s += c 
    c += 1
    if s >= n:
        break

print(s)

6087

n = int(input())

for i in range(1, n+1):
    if i%3 == 0:
        continue
    print(i, end=' ')

6088

a, d, n = map(int, input().split())
count = 1 #a+b부터가 2번째 숫자여서 처음값을 1로 설정

while True:
    a += d 
    count += 1
    if count == n:
        break

print(a)

6089

a, r, n = map(int, input().split())
count = 1 

while True:
    a *= r 
    count += 1
    if count == n:
        break

print(a)

6090

a, m, d, n = map(int, input().split())
count = 1 

for i in range(n-1):
    a = a*m+d
print(a)

#첫번째, 즉 range에서 0은 처음 지정한 a의 값이 아닌 계산된 2번째 수열이 해당되기 때문에 range(n-1)임
#range(n)으로 했을 때 출력결과는 -1 3 -5 11 -21  임

6091

a, b, c = map(int, input().split())
d = 1

while True:
    if d%a==0 and d%b==0 and d%c==0:
        break
    d += 1

print(d)

#문제 제공코드 사용 - 더 빠름
a, b, c = map(int, input().split())
d = 1

while d%a!=0 or d%b!=0 or d%c!=0:
    d += 1
print(d)

6092

n = int(input())
a = input().split()

for i in range(n):
    a[i] = int(a[i])

d = []
for i in range(24):
    d.append(0)

for i in range(n):
    d[a[i]] += 1

for i in range(1, 24):
    print(d[i], end = ' ')

6093

#문제에 제공된 코드 사용
n = int(input())
k = input().split()

for i in range(n-1, -1, -1):
    print(k[i], end=' ')

#다른풀이
n = int(input())
k = input().split()

a = list(reversed(k))
b = list(map(int, a))
c = str(b)[1:-1]
print(c.replace(",",""))

6094

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

print(min(k))

6095

d = [[0 for j in range(20)] for i in range(20)]

n = int(input())
for i in range(n):
    x, y = input().split()
    d[int(x)][int(y)] = 1

for i in range(1, 20):
    for j in range(1, 20):
        print(d[i][j], end=' ')
    print()


d = []
for i in range(20):
    d.append([])
    for j in range(20):
        d[i].append(0)

n = int(input())
for i in range(n):
    x, y = input().split()
    d[int(x)][int(y)] = 1

for i in range(1, 20):
    for j in range(1, 20):
        print(d[i][j], end=' ')
    print()

6096

d = []
for i in range(20):
    d.append([])
    for j in range(20):
        d[i].append(0)

for i in range(1, 20):
    data = input().split()
    for j in range(1, 20):
        d[i][j] = int(data[j-1]) 
        
n = int(input())

for i in range(n):
    x,y = input().split()
    for j in range(1,20):
        if d[j][int(y)]==1:
            d[j][int(y)]=0
        else:
            d[j][int(y)]=1

        if d[int(x)][j]==1:
            d[int(x)][j]=0
        else:
            d[int(x)][j]=1

for i in range(1, 20):
    for j in range(1, 20):
        print(d[i][j], end=' ')
    print()

6097

h, w = map(int, input().split())

a = []
for i in range(h):
    a.append([])
    for j in range(w):
        a[i].append(0)

n = int(input())

for i in range(n):
    l, d, x, y = map(int,input().split())
    for j in range(l):
        a[int(x-1)][int(y-1)] = 1
        if d == 1:
            x += 1
        elif d == 0:
            y += 1

for i in range(h):
    for j in range(w):
        print(a[i][j], end=' ')
    print()

6098

d = [[0 for j in range(10)] for i in range(10)]

for i in range(10):
    d[i] = list(map(int, input().split()))

x = 1
y = 1

while True:
    if d[x][y] == 0:
        d[x][y] = 9
    if d[x][y] == 2:
        d[x][y] = 9
        break
    if d[x][y+1] == 1 and d[x+1][y] == 1:
        break
    if d[x][y+1] != 1:
        y += 1
    elif d[x+1][y] != 1:
        x += 1

for i in range(10):
    for j in range(10):
        print(d[i][j], end=' ')
    print()

6060

i, h = map(int, input().split())
print(int(i&h))

6061

i, h = map(int, input().split())
print(int(i|h))

6062

i, h = map(int, input().split())
print(int(i^h))

6063

i, h = map(int, input().split())
print(i if (i>h) else h)

i, h = map(int, input().split())
print(i if (i>=h) else h)

6064

i, h, j = map(int, input().split())
print((i if i<h else h) if ((i if i<h else h)<j) else j)

6065

i, h, j = map(int, input().split())
if i%2==0:
    print(i)
if h%2==0:
    print(h)
if j%2==0:
    print(j)

6066

i, h, j = map(int, input().split())
if i%2==0:
    print("even")
else:
    print("odd")
if h%2==0:
    print("even")
else:
    print("odd")
if j%2==0:
    print("even")
else:
    print("odd")

6067

i = int(input())
if i<0 :
    if i%2==0:
        print('A')
    else:
        print('B')
else:
    if i%2==0:
        print('C')
    else:
        print('D')

6068

i = int(input())
if i>=90:
    print('A')
else:
    if i>=70:
        print('B')
    else:
        if i>=40:
            print('C')
        else:
            print('D')

6069

i = input()
if i=='A':
    print('best!!!')
elif i=='B':
    print('good!!')
elif i=='C':
    print('run!')
elif i=='D':
    print('slowly~')
else:
    print('what?')

6070

i = int(input())
if i//3==1:
    print('spring')
elif i//3==2:
    print('summer')
elif i//3==3:
    print('fall')
else:
    print('winter')

6071

n = 3 
while n!=0 :
  n = int(input())
  if n!=0 :
    print(n)

6072

n = int(input())
while n!=0:
    print(n)
    n = n-1

6073

i = int(input())
while i!=0:
    print(i-1)
    i = i-1

6074

i = ord(input())
h = ord('a')
while h<=i:
    print(chr(h), end=' ')
    h += 1

6075

i = int(input())
h = int('0')
while h<=i:
    print(int(h))
    h+=1

6076

i = int(input())
h = int('0')
while h<=i:
    print(int(h))
    h+=1

6077

i, h = 2, 0 
a = int(input())
while i <= a:
  h += i 
  i += 2 
print (h)

6078

i = ''
while i!='q':
    i = input()
    print(i)

6079

i = int(input())
h, j = 0, 0
while j<i :
  h+=1
  j+=h  

print(h)

6040

i, h = input().split()
i = int(i)
h = int(h)
print(i//h)

6041

i, h = input().split()
i = int(i)
h = int(h)
print(i%h)

6042

i = input()
i = float(i)
print(format(i, '.2f'))

6043

i1, i2 = input().split()
i1 = float(i1)
i2 = float(i2)
print(format(i1/i2, '.3f'))

6044

i, h = input().split()
i = int(i)
h = int(h)
print(i+h)
print(i-h)
print(i*h)
print(i//h)
print(i%h)
print(format(i/h, '.2f'))

6045

i, h, j = map(int, input().split())
print(i+h+j, format((i+h+j)/3, '.2f'))

6046

i = int(input())
print(i<<1)

6047

i, h = map(int, input().split())
print(i<<h)

6048

i, h = map(int, input().split())
print(i<h)

6049

i, h = map(int, input().split())
print(i==h)

6050

i, h = map(int, input().split())
print(i<=h)

6051

i, h = map(int, input().split())
print(i!=h)

6052

i = int(input())
print(i!=0)

6053

i = bool(int(input()))
print(not i)

6054

i, h = input().split()
print(bool(int(i)) and bool(int(h)))

6055

i, h = input().split()
print(bool(int(i)) or bool(int(h)))

6056

i, h = input().split()
i = bool(int(i))
h = bool(int(h))
print((i and (not h)) or ((not i) and h))

6057

i, h = input().split()
i = bool(int(i))
h = bool(int(h))
print(((not i) and (not h)) or (i and h))

6058

i, h = input().split()
i = bool(int(i))
h = bool(int(h))
print(not(i or h))

6059

i = int(input())
i = ~i 
print(int(i))

6020

i, h= input().split('-')
print(i, h, sep='')

6021

i = input()
print(i[0])
print(i[1])
print(i[2])
print(i[3])
print(i[4])

6022

i = input()
print(i[0:2], i[2:4], i[4:6])

6023

i, h, j = input().split(':')
print(h)

6024

i, h = input().split()
j = i + h
print(j)

6025

i, h = input().split()
j = int(i) + int(h)
print(j)

6026

i = input()
h = input()
i = float(i)
h = float(h)
print(i + h)

6027

i = input()
i = int(i)
print('%x' %i)

6028

i = input()
i = int(i)
print('%X' %i)

6029

i = input()
h = int(i, 16)
print('%o' %h)

6030

i = ord(input())
print(i)

6031

i = int(input())
print(chr(i))

6032

i = int(input())
print(-i)

6033

i = input()
i = ord(i)
print(chr(i+1))

6034

i, h = input().split()
i = int(i)
h = int(h)
print(i-h)

6035

i1, i2 = input().split()
i1 = float(i1)
i2 = float(i2)
print(i1 * i2)

6036

i, h = input().split()
print(i*int(h))

6037

i = input()
h = input()
print(int(i)*h)

6038

i, h = input().split()
i = int(i)
h = int(h)
print(i**h)

6039

i1, i2 = input().split()
i1 = float(i1)
i2 = float(i2)
print(i1**i2)

 

6001

print('Hello')

6002

print('Hello', 'World')

6003

print('Hello')
print('World')

6004

print("'Hello'")

6005

print('"Hello World"')

6006

print('\"!@#$%^&*()\'')

6007

print('\"C:\\Download\\\'hello\'.py\"')

6008

print('print(\"Hello\\nWorld\")')

6009 

i = input()
print(i)

6010

i = input()
i = int(i)
print(i)

 

6011

i = input()
i = float(i)
print(i)

6012

i = input()
h = input()

i = int(i)
h = int(h)

print(i)
print(h)

6013

i = input()
h = input()

print(h)
print(i)

6014

i = input()
i = float(i)
print(i)
print(i)
print(i)

6015

i, h = input().split()
i = int(i)
h = int(h)
print(i)
print(h)

6016

i, h = input().split()
print(h, i)

6017

i = input()
print(i, i, i)

6018

i, h = input().split(':')
print(i, h, sep=':')

6019

y, m, d = input().split('.')
print(d, m, y, sep='-')