一口井深len米,蜗牛白天爬m米,晚上滑下去n米,几天到井口?实现爬井函数climb输出答案,简单起见len,m,n都是整数。例如:一口井深10米,蜗牛白天爬4米,晚上滑下去3米,最终应该是7天到达井口。
示例1
输入
10,4,3
输出
7
说明
正常
示例2
输入
11,10,10
输出
-1
说明
异常
加载中...
import java.util.*; public class Solution { /** * 蜗牛到达井口所需天数 * @param len int整型 井深 * @param m int整型 白天爬m米 * @param n int整型 晚上滑下去n米 * @return int整型 */ public int daycost (int len, int m, int n) { // write code here } }
class Solution { public: /** * 蜗牛到达井口所需天数 * @param len int整型 井深 * @param m int整型 白天爬m米 * @param n int整型 晚上滑下去n米 * @return int整型 */ int daycost(int len, int m, int n) { // write code here } };
# # 蜗牛到达井口所需天数 # @param len int整型 井深 # @param m int整型 白天爬m米 # @param n int整型 晚上滑下去n米 # @return int整型 # class Solution: def daycost(self , len , m , n ): # write code here
/** * 蜗牛到达井口所需天数 * @param len int整型 井深 * @param m int整型 白天爬m米 * @param n int整型 晚上滑下去n米 * @return int整型 */ function daycost( len , m , n ) { // write code here } module.exports = { daycost : daycost };
# # 蜗牛到达井口所需天数 # @param len int整型 井深 # @param m int整型 白天爬m米 # @param n int整型 晚上滑下去n米 # @return int整型 # class Solution: def daycost(self , len , m , n ): # write code here
package main /** * 蜗牛到达井口所需天数 * @param len int整型 井深 * @param m int整型 白天爬m米 * @param n int整型 晚上滑下去n米 * @return int整型 */ func daycost( len int , m int , n int ) int { // write code here }
/** * 蜗牛到达井口所需天数 * @param len int整型 井深 * @param m int整型 白天爬m米 * @param n int整型 晚上滑下去n米 * @return int整型 */ int daycost(int len, int m, int n ) { // write code here }
10,4,3
7
11,10,10
-1