# 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; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up