[백준] 10988, 5086, 5717, 9610, 9506, 10162, 10103 (파이썬)

Colacan·2022년 1월 27일
1

[백준]

목록 보기
11/43

이제는 규칙적으로 알고리즘 연습하는 것이 익숙해진 듯하다. 백준 티어도 실버2로 올랐다. 1차목표가 눈에 보이니 더 의욕이 생기는 느낌이다.

백준 10988번 팰린드롬인지 확인하기

import math
pallin = input()
count = 0
for i in range(int(math.ceil((len(pallin)-1)/2))):
    if pallin[i]==pallin[len(pallin)-i-1]:
        count+=1
if count == int(math.ceil((len(pallin)-1)/2)):
    print(1)
else:
    print(0)

백준 5086번 배수와 약수

while True:
    num1,num2 = map(int,input().split())
    if num1==0 and num2==0:
        break
    else:
        if num2%num1 == 0 :
            print('factor')
        elif num1%num2 == 0 :
            print('multiple')
        else :
            print('neither')

백준 5717번 상근이의 친구들

while True:
    M,F = map(int,input().split())
    if M==0 and F==0:
        break
    else:
        print(M+F)

백준 9610번 사분면

n = int(input())
Q1,Q2,Q3,Q4,AXIS = 0,0,0,0,0
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 or y == 0:
        AXIS += 1
    elif x > 0 and y > 0:
        Q1 += 1
    elif x < 0 and y > 0:
        Q2 += 1
    elif x < 0 and y < 0:
        Q3 += 1
    elif x > 0 and y < 0:
        Q4 += 1
print("Q1: " +str(Q1))
print("Q2: " +str(Q2))
print("Q3: " +str(Q3))
print("Q4: " +str(Q4))
print("AXIS: " +str(AXIS))

백준 9506번 약수들의 합

while True:
    n = int(input())
    n_list = list()
    if n==-1:
        break
    else:
        for i in range(1,n):
            if n%i==0:
                n_list.append(i)
        if n==sum(n_list):
            print(str(n) + ' = ' + " + ".join(str(j) for j in n_list))
        else:
            print(str(n)+' is NOT perfect.')

백준 10162번 전자레인지

T = int(input())
A,B,C = 0,0,0
if T%10==0:
    A = T//300
    B = (T%300)//60
    C = ((T%300)%60)//10
    print(A,B,C)
else:
    print(-1)

백준 10103번 주사위 게임

n = int(input())
chang,sang = 100,100
for i in range(n):
    num1,num2 = map(int,input().split())
    if num1>num2:
        sang-=num1
    elif num1<num2:
        chang-=num2
print(chang)
print(sang)
profile
For DE, DA / There is no royal road to learning

0개의 댓글