Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 편스토랑 우승상품
- gs25
- hackerrank
- 더현대서울 맛집
- 캐치카페
- ChatGPT
- 자연어처리
- 코로나19
- SW Expert Academy
- 프로그래머스
- 금융문자분석경진대회
- 파이썬
- leetcode
- 프로그래머스 파이썬
- PYTHON
- programmers
- 맥북
- Baekjoon
- Real or Not? NLP with Disaster Tweets
- dacon
- 편스토랑
- 백준
- Git
- ubuntu
- Docker
- 데이콘
- Kaggle
- AI 경진대회
- 우분투
- github
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 4969번 : St. Ives (Python) 본문
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 St. Ives 입니다.
4696번: St. Ives
Input consists of multiple data sets. Each data set consists of a line with a single floating point number number representing the numbers of wives, sacks per wife, cats per sack, and kittens per cat that Robert encountered that year. End of input is indic
www.acmicpc.net
👨🏻💻 문제 풀이
어떤 숫자를 입력 받으면
해당 숫자의 1제곱, 2제곱, 3제곱, 4제곱 그리고 1을 더한 값을 구하는 문제입니다.
제곱을 구하는 것은 pow 를 활용 하였습니다.
answer = pow(num, 1) + pow(num, 2) + pow(num, 3) + pow(num, 4) + 1
소수점 두자리까지 무조건 출력하는 것에는 소수점 세번째 자리에서 반올림을 하고
%.2f 를 활용하여 정답 형식을 만들었습니다.
def make_answer_format(answer):
answer = round(answer, 2)
return "%.2f"%answer
👨🏻💻 코드 ( Solution )
def make_answer_format(answer):
answer = round(answer, 2)
return "%.2f"%answer
def st_ives(num):
answer = pow(num, 1) + pow(num, 2) + pow(num, 3) + pow(num, 4) + 1
return make_answer_format(answer)
if __name__ == "__main__":
while True:
num = float(input())
if num == 0:
break
print(st_ives(num))
GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 15792번 : A/B - 2 (Python) (0) | 2022.08.21 |
---|---|
[BaekJoon] 17202번 : 핸드폰 번호 궁합 (Python) (0) | 2022.08.20 |
[BaekJoon] 24416번 : 알고리즘 수업 - 피보나치 수 1 (Python) (0) | 2022.08.16 |
[BaekJoon] 2083번 : 럭비 클럽 (Python) (0) | 2022.08.15 |
[BaekJoon] 10174번 : 팰린드롬 (Python) (0) | 2022.08.14 |