일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
Tags
- C++
- Daily Commit
- adjacentElementsProduct
- recursion
- shapeArea
- codesingal
- Counting cells in a blob
- matrixElementsSum
- 파이썬머신러닝완벽가이드
- 2015 봄학기 알고리즘
- markdown
- almostIncreasingSequence
- collections.deque
- 백준
- 피보나치 수
- cpp
- 2750
- Sequential Search
- baekjun
- Python
- 10953
- All Longest Strings
- data_structure
- codesignal
- 파이썬 포렌식
- centuryFromYear
- 수 정렬하기
- Numpy
- til
- flask
Archives
- Today
- Total
Introfor
[Intro] centuryFromYear 본문
Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
주어진 년도로 세기를 반환하는 문제. 1세기는 1년~100년까지이고, 101년부터 200년까지 2세기를 뜻한다.
def centuryFromYear(year):
if(year%100==0):
return year//100
else:
return (year//100)+1
주어진 year가 100으로 나눴을 때 나누어 떨어지면 그 몫이 1세기를 반환하고, 나누어 떨어지지 않으면 나눠서 나온 몫의 +1을 해주면 그 년도의 해당 세기값을 반환한다.
'Programming_prob > Codesignal' 카테고리의 다른 글
[Intro] Make Array Consecutive 2 (0) | 2020.07.18 |
---|---|
[Intro] shapeArea (0) | 2020.07.18 |
[Intro] adjacentElementsProduct (0) | 2020.07.18 |
[Intro] checkPalindrome (0) | 2020.07.18 |
[Intro] add (0) | 2020.07.18 |
Comments