일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- stl
- spring
- Flexbox
- Photoshop
- margin
- c
- Javascript
- skt membership
- align-items
- Prefix Sums
- 소수
- grid
- 알고리즘
- 통신사할인
- series
- Codility
- c++
- 포토샵
- 에라토스테네스의 체
- 확률
- CSS
- pandas
- Gap
- 백준
- Design Pattern
- SK바이오사이언스
- 강화학습
- dataframe
- 수학
- 상태
Archives
- Today
- Total
sliver__
Codility : Lesson 3 (Time complexity) - FrogJmp 본문
728x90
안녕하세요~~
디벨롭퍼입니다~~~

오늘은 Lesson3 (Time complexity) : FrogJmp 문제를 풀어보았습니다.
https://app.codility.com/programmers/lessons/3-time_complexity/frog_jmp/
FrogJmp coding task - Learn to Code - Codility
Count minimal number of jumps from position X to Y.
app.codility.com
***********************************************************************
풀어보실 분들을 위해서 링크 걸어두었습니다.
***********************************************************************
주어진 문제는 아래와 같습니다.
시작점의 위치 : X
도착점의 위치 : Y
한번에 이동할 수 있는 거리 : D
위 3가지가 파라미터로 주어집니다.
X <= Y 인 개구리가 움직인 횟수를 구하는 문제입니다.
제출한 코드는 아래와 같습니다.
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
int solution(int X, int Y, int D) {
// write your code in C++14 (g++ 6.2.0)
return ((Y-X) % D > 0) ? ((Y-X)/D + 1) : ((Y-X)/D);
}
다음 문제에서 만나요~~
그럼 이만~~~

728x90
'CS > Codility' 카테고리의 다른 글
Codility : Lesson 3 (Time complexity) - TapeEquilibrium (0) | 2021.09.27 |
---|---|
Codility : Lesson 3 (Time complexity) - PermMissingElem (0) | 2021.09.26 |
Codility : Lesson 2 (Array) - OddOccurrencesInArray (0) | 2021.09.24 |
Codility : Lesson 2 (Array) - CyclicRotation (0) | 2021.09.23 |
Codility : Lesson 1 (Iterator) (0) | 2021.09.22 |
Comments