题目描述 我们可以用2\ 1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2\ 1的小矩形无重叠地覆盖一个2 n的大矩形,总共有多少种方法? 思路 斐波那契问题。 时间复杂度O(n),空间复杂度O(1)。 代码 java public class Solution { public int Rec ...
分类:
其他好文 时间:
2020-02-16 21:02:37
阅读次数:
81
题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 思路 斐波那契数列变种。 1. f(n)=f(n 1)+f(n 2)+……f(1) f(n 1)=f(n 2)+……f(1) 两式相减得f(n)=2f(n 1) 时间复杂度O(n ...
分类:
其他好文 时间:
2020-02-16 13:14:30
阅读次数:
68
[toc] ? 893. 特殊等价字符串组 https://leetcode cn.com/problems/groups of special equivalent strings 描述 ? 811. 子域名访问计数 https://leetcode cn.com/problems/subdoma ...
分类:
其他好文 时间:
2020-02-16 12:49:09
阅读次数:
92
#include<bits/stdc++.h> using namespace std; struct bign{ int d[10000]; int len; bign(){ memset(d,0,sizeof(d)); len = 0; } }; //字符串转到大数中 bign change(c ...
分类:
其他好文 时间:
2020-02-14 22:55:40
阅读次数:
97
package com.lv.study; public class DemoAm4 { //斐波那契数列:生兔子 :从1和1开始 后面一个数等于前面两个数之和 public static void main(String[] args) { test2(); } public static voi ...
分类:
其他好文 时间:
2020-02-13 21:08:56
阅读次数:
76
爬楼梯。题意是给一个数字n代表楼梯的高度,你可以每次爬一步或者两步,求有多少种不同的爬法。例子, Example 1: Input: 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step ...
分类:
其他好文 时间:
2020-02-13 09:56:32
阅读次数:
70
题意: 给定一个$k$维的$n^k$的超立方体,超立方体的元素$A(i1,i2,...,ik)$的值为$f(i1+i2+...+ik k+1)$,f为斐波那契数列 求该超立方体的所有元素和 $1 \le n,k \le 10^9$ 输入样例 3 2 2 4 1 1 3 输出样例 5 7 1 题解 自 ...
分类:
其他好文 时间:
2020-02-12 22:36:39
阅读次数:
85
这次内容很多,比较重要 1、购物登陆(伪代码) user = 'hanjie'passwd = 123w_user = 'hanjie123'w_passwd = 123login_states = Falsedef login(): if login_states== False: if auth ...
分类:
其他好文 时间:
2020-02-12 00:43:42
阅读次数:
90
题解: 这其实是变相的斐波那契,观察下列等式: //k=2 : 1 2 3 5 8 13 21 34...... //k=3 : 1 2 4 7 13 24 44 81... //k=4 : 1 2 4 8 15 29 56 108... //k=5 : 1 2 4 8 16 31 61 120.. ...
分类:
其他好文 时间:
2020-02-11 11:24:55
阅读次数:
62
输出: Console.WirteLine("hello world"); string a="hello world"; Console.WirteLine(a); string a="world"; Console.WirteLine("hello"+a); string a="hello wo ...