일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- brute force
- springboot
- 백준
- spring security
- 알고리즘
- 코딩테스트
- error
- 탐욕법
- 문자열
- API
- Greedy
- beandefinitionstoreexception
- 2981
- Python
- javascript
- 최단경로
- Spring
- HTTP
- 파이썬
- codility
- counting elements
- 라이브템플릿
- Dijkstra
- applicationeventpublisher
- algorithm
- 프로그래머스
- java
- 2018 KAKAO BLIND RECRUITMENT
- BFS
- 소수
Archives
- Today
- Total
목록분수찾기 (1)
Altiora Petamus
분수찾기
Reference 백준 1193번 문제풀이 대각방향으로 1, 2, 3, 4, 5개만큼 새로운 분수가 생성된다 ⇒ 14는 10과 15의 사이에 있으므로 14번째 분수는 5열 중 어느 한 곳에 있다. 홀짝을 사용하여 차례를 알 수 있다. 5열은 홀수번째이며, 분모가 1부터 시작해서 1씩 증가한다. 분자는 반대. 위 내용을 코드로 작성한다면 아래와 같이 작성할 수 있다. X = int(input()) totalLine = 0 temp = 0 while X > totalLine: temp += 1 totalLine += temp a = 1 b = temp n = totalLine - X if b % 2 != 0: print(f'{a + n}/{b - n}') else: print(f'{b - n}/{a + n}..
1day-1algorithm
2021. 4. 18. 21:17