ICode9

精准搜索请尝试: 精确搜索
  • scipy库的介绍(Python)2022-07-03 10:32:18

    scipy库的介绍(Python) 在科学计算中,图像通常被看做n维数组。图像一般是二维数组,它能被表示为NumPy数组的数据结构。NumPy是一个运行速度非常快的数学库,主要用于数组计算。它可以让你在 Python 中使用向量和数学矩阵,以及许多用 C 语言实现的底层函数 在数据可视化中,最著名的是matplo

  • 1419B - Stairs2022-06-19 11:01:01

    思维: 我们可以发现,nice stairs的长度为1,3,7,15... 不难发现,长度变化每次*2+1,而每次长度的nice stairs是等差数列,所以当长度为n时,一共有\(\frac{n*(n+1)}{2}\)个正方形 #include <iostream> using namespace std; long long n; int main () { int T; cin >> T; while (T--) { ci

  • LeetCode 0070 Climbing Stairs2022-04-24 07:00:47

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 n result 说明 1 1 爬1个台阶 2 2 1 + 1 3 3 从第1级台阶到达或从第2级台阶到达 f(1) + f(2) ...... n f(n) f(n-1) + f(n-2) 实际上就是求Fibonacci 数列 2、代码实现 实现1: 迭代 package Q0099.Q007

  • 动态规划——LeetCode70.爬楼梯2021-10-03 11:02:21

    文章目录 一、题目二、题解 一、题目 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2 输出: 2 解释: 有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例

  • CF1553I Stairs2021-08-25 13:00:37

    题面传送门 zj:这种屑题最多评个蓝 首先判一下无解,然后将同样的缩成一个点。 然后设\(f_i\)为最后有\(i\)个联通块的答案,所以最后答案容斥一下就好了。 这个东西分治的时候NTT合并答案就好了。 有亿点卡常,时间复杂度\(O(nlog^2n)\) code: #include<bits/stdc++.h> #pragma GCC opti

  • 动态规划之Climbing Stairs(爬楼梯) java实现2020-12-24 17:57:39

    问题 有一个楼梯,总共有n阶台阶。每一次,可以上一个台阶,也可以上两个台阶。问,爬这样的一个楼梯,一共有多少不同的方法? 如n=3,可以爬上这个梯子的方法有:[1,1,1],[1,2],[2,1],所以答案为3。 问题分析 动态规划的问题,我们先把问题转化为递归问题进行分析: 看到上面的图,大家是不是有一

  • [LeetCode] 746. Min Cost Climbing Stairs2020-11-10 02:31:28

    On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with i

  • leetcode刷题-70爬楼梯2020-08-08 10:00:26

    题目 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 思路 最开始使用的是回溯的方法,但是时间效率地下没有通过,于是想到了动态规划的算法。对于i楼梯,到达其的方法有从i-1跨一步和i-

  • climbing-stairs2020-07-24 20:33:35

    题目描述 你在爬楼梯,需要n步才能爬到楼梯顶部 每次你只能向上爬1步或者2步。有多少种方法可以爬到楼梯顶部?   递归法: 1 import java.util.*; 2 3 4 public class Solution { 5 /** 6 * 7 * @param n int整型 8 * @return int整型 9 */

  • 746. Min Cost Climbing Stairs2020-07-06 12:35:04

    On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with i

  • 爬楼梯(Python and C++解法)2020-06-18 22:54:47

    题目: 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/climbing-stairs 思路:   使用动态规划的基本思想,到第n个台阶的方法等于

  • LeetCode不定时刷题——Climbing Stairs2020-03-08 18:00:33

    Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2 Output:

  • 算法题LC79:climbing-stairs2020-03-05 14:03:04

    动态规划: 题目描述: 你在爬楼梯,需要n步才能爬到楼梯顶部 每次你只能向上爬1步或者2步。有多少种方法可以爬到楼梯顶部? You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can

  • 北京大学 程序设计与算法(二) 递归 上台阶2020-02-29 14:02:33

    用递归将问题分解为规模更小的子问题进行求解 爬楼梯 树老师爬楼梯,他可以每次走1级或者2级,输入楼梯的级数,求不同的走法数。 例如:楼梯一共有3级,他可以每次都走一级,或者第一次走一级,第二次走两级,也可以第一次走两级,第二次走一级,一共3中方法。   输入 输入包括若干行,每行包含一个正

  • leetcode 70. 爬楼梯2020-02-28 09:04:12

    目录 1. 解法 1.1. 暴力穷举 1.2. 记忆化递归 1.3. 动态规划 1.4. 斐波那契数列 1. 解法 1.1. 暴力穷举 把所有可能爬的阶数进行组合,就是1和2。 在每一步中都会继续调用climb_stairs函数模拟爬1阶和2阶的情形,并返回两个函数的返回值之和。 climb_stairs(i, n) = climb_sta

  • 动态规划-2-12020-02-01 09:00:53

    最大子序和 public int crossSum(int[] nums, int left, int righ, int p){ if(left == right) return nums[left]; int leftSubsum = Integer.MIN_VALUE; int currSum = 0; for(int i=p;i > left -1; --i){ currSum += nums[i]; le

  • leetCode 您正在爬楼梯。它需要n步才能到达顶部。每次您可以爬1或2步。您可以通过几种不同的方式登顶?2019-11-27 18:53:50

    找抄的,不明白!!! public static int climbStairs(int n) { return climb_Stairs(0, n); } public static int climb_Stairs(int i, int n) { if (i > n) { return 0; } if (i == n) { return 1; }

  • 70.Climbing Stairs2019-07-08 13:00:35

    递归解决方法 public class Main { int sum = 0; public int climbStairs(int n) { if (n <= 0) {// sum++; } else if (n == 1) { sum++; } else { climbStairs(n - 1);//每一种结果都有两种选择 要么

  • letecode [70] - Climbing Stairs2019-06-06 10:48:46

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2Output: 2Explanation: There

  • LeetCode【#70】 Climbing Stairs2019-05-19 21:49:25

    题目链接: 点击跳转   题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Inp

  • LeetCode - climbing-stairs2019-05-03 18:54:31

    题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?   题意: 你正在爬楼梯。到达山顶需要n步。 每次你可以爬1或2级台阶。你可以用几种不同的

  • 爬楼梯2019-04-27 19:41:49

    题目: 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2输出: 2解释: 有两种方法可以爬到楼顶。1. 1 阶 + 1 阶2. 2 阶方法一:暴力法,直接用递归实现 class Solution {

  • 【LeetCode】Climbing Stairs(爬楼梯)2019-04-21 19:54:56

    这道题是LeetCode里的第70道题。 题目描述: 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2 输出: 2 解释: 有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶

  • 70. Climbing Stairs2019-04-15 14:55:22

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2 Output: 2 Explanation

  • Leetcode之Climbing Stairs2019-04-08 11:49:01

    题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2 Output: 2 Explana

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有