# L3-FrogJmp ###### tags: `Codility_lessons` ## Question https://app.codility.com/programmers/lessons/3-time_complexity/frog_jmp/ ## Key 這題本來用loop一直將目標距離減跳距,但會time exceed,後來用除的 ## Reference ## Solution ```cpp= #include <iostream> using namespace std; int solution(int X, int Y, int D) { if(X<Y) { if((Y-X)%D != 0) { return ((Y-X)/D)+1; } return ((Y-X)/D); } return 0; } ```