본문 바로가기
Python/Baekjoon

[BOJ] Bronze Ⅴ- Day 2

by 단월໒꒱ 2021. 12. 28.

사용 언어 : Python, C

푼 문제 : #2475, #2557, #2558, #2845, #2914

 

 

 

#2475

 

[Python]

 

num1, num2, num3, num4, num5 = map(int, input().split())
sum = num1 ** 2 + num2 ** 2 + num3 ** 2 + num4 ** 2 + num5 ** 2
print(sum % 10)

 

이렇게 하긴 했지만 리스트 써서 하면 더 간단해질 듯!

 

 

#2557

 

[Python]

 

print("Hello World!")

 

[C]

 

#include <stdio.h>
int main(void) {
    printf("Hello World!");
    return 0;
}

 

 

#2558

 

[Python]

 

A = int(input())
B = int(input())
print(A + B)

 

 

#2845

 

[Python]

 

L, P = map(int, input().split())
people = list(map(int, input().split()))
result = P * L
for i in people :
    print(i - result, end = ' ')

 

이번엔 리스트를 써봤다. 코드가 훨씬 간결해졌다.

 

 

#2914

 

[Python]

 

num, avg = map(int, input().split())
print(num * (avg - 1) + 1)

 

문제를 역으로 생각하면 된다. 나눠서 평균을 구한 거니까 다시 곱해서 구하고자 하는 값을 구하면 된다. 

 

 

 

'Python > Baekjoon' 카테고리의 다른 글

[BOJ] Bronze Ⅴ- Day 12  (0) 2022.01.08
[BOJ] Bronze Ⅴ- Day 11  (0) 2022.01.08
[BOJ] Bronze Ⅴ- Day 10  (0) 2022.01.05
[BOJ] Bronze Ⅴ- Day 3  (0) 2021.12.29
[BOJ] Bronze Ⅴ- Day 1  (0) 2021.12.27

댓글