1. 青蛙跳跳FrogJmp Count minimal number of jumps from position X to Y.
青蛙跳跳;
package com.code;public class Test03_1 {public int solution(int X, int Y, int D) {int res = (Y-X)/D+((Y-X)%D==0?0:1);return res;}public static void main(String[] args) {Test03_1 t03 = new Test03_1();System.out.println(t03.solution(10, 85, 30));} }/**A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.Count the minimal number of jumps that the small frog must perform to reach its target.Write a function:class Solution { public int solution(int X, int Y, int D); }that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.For example, given:X = 10Y = 85D = 30 the function should return 3, because the frog will be positioned as follows:after the first jump, at position 10 + 30 = 40 after the second jump, at position 10 + 30 + 30 = 70 after the third jump, at position 10 + 30 + 30 + 30 = 100 Assume that:X, Y and D are integers within the range [1..1,000,000,000]; X ≤ Y. Complexity:expected worst-case time complexity is O(1); expected worst-case space complexity is O(1).* * * */
1. 青蛙跳跳FrogJmp Count minimal number of jumps from position X to Y.相关推荐
- 1990 Count the Number of Experiments
题目描述: Write an SQL query to report the number of experiments done on each of the three platforms for ...
- Jumping Jack(翻译)
2022.2.18 题目网址: https://codeforces.com/contest/11/problem/B 题目: Jumping Jack 1000ms 65536K 描述: Jack ...
- 什么是游戏开发的实体系统框架
原文地址:http://blog.csdn.net/aisajiajiao/article/details/19011259 上周我发布了Ash,一个Actionscript游戏开发实体系统框架,许多 ...
- 什么是游戏开发的实体系统框架 What is an entity system framework for game development
原文地址 上周我发布了Ash,一个Actionscript游戏开发实体系统框架,许多人问我这个问题"什么是实体系统框架?"本文就是我详尽的答案. 实体系统逐渐流行起来了,比较著名的 ...
- Bezier曲线切割
贝塞尔曲线 目标:在unity中展示Bezier曲线. 贝塞尔曲线原理 用代码实现 bezier数学公式 Bezier公式(一般参数公式) 注解: 阶贝兹曲线可如下推断.给定点P0.P1.-.Pn,其 ...
- LeetCode 204. Count Primes--从一开始的质数个数--Python解法--面试算法题
题目地址:Count Primes - LeetCode Count the number of prime numbers less than a non-negative number, n. E ...
- LeetCode 673. Number of Longest Increasing Subsequence--O(N log N )--Java,C++,Python解法
题目地址:Number of Longest Increasing Subsequence - LeetCode 做这道题目前建议先做:Longest Increasing Subsequence - ...
- LeetCode 200. Number of Islands--c++ dfs解法
LeetCode 200. Number of Islands LeetCode题解专栏:LeetCode题解 LeetCode 所有题目总结:LeetCode 所有题目总结 大部分题目C++,Pyt ...
- [LeetCode] Count Primes
Description: Count the number of prime numbers less than a non-negative number, n 解题思路 采用Eratosthene ...
最新文章
- ES6 let和const 命令
- AngularJs表单自动验证
- HTML DOM之节点操作方法(2)
- JAVA面试题:你怎么设计一个消息队列?
- Docker本地私有仓库的建立
- 图像目标检测(Object Detection)原理与实现(三)
- TeXmacs - 所见即所得 - 专业排版软件
- php workerman定时任务
- Android新增usb Audio(mic)设备
- 谭浩强 c语言 swap,C语言谭浩强完整教案.ppt
- JSP九大内置对象的作用和用法
- 蓝桥杯 基础练习 杨辉三角形 JAVA
- 下载百度文库的受限文件-冰点下载器
- 计算机上word如何批量打印,Word2010怎样批量打印证书
- openwrt中luci学习笔记
- 【微机】ALU的核心就是带标志加法器
- 用Unity的GetSpectrumData方法识别钢琴曲中的钢琴琴键
- 分享一个边看视频就能边练口语的学习网站,超实用,不仅仅能学英语
- 掺铥铝酸钇晶体(Tm:YAP)晶体的资料及其相关产品目录
- 锐龙r74800h和i710750h差距大吗 r74800h和i710750h对比
热门文章
- requestWindowFeature()的应用
- Android常见面试题
- javascript BOM对象详解
- mysql orm .net,2020年 .NET ORM 完整比较、助力选择
- 美特斯邦威java面试_在美特斯邦威工作一个月,我学到了什么
- java表底层生产工具_使用Java工具解决生产故障(一)-jcmd介绍
- 福州大学2013java期末试卷_2020-11-04:java里,总体说一下集合框架。
- mysql plugin 调用_MySQL插件接口的调用方式
- cobbler安装和基本配置
- [20180818]校内模拟赛