这题和62题类似,只不过这里多了障碍物,只需要把有障碍物的格子的方案数设置为0即可,其他格子还是原来的走法。 class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) { int ...
分类:
其他好文 时间:
2020-06-29 11:41:08
阅读次数:
36
1. class Solution { public: int missingNumber(vector<int>& nums) { sort(nums.begin(),nums.end()); for(int i=0;i<nums.size();++i) { if(nums[i]!=i) retu ...
分类:
其他好文 时间:
2020-06-29 11:35:36
阅读次数:
47
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo ...
分类:
其他好文 时间:
2020-06-29 00:18:05
阅读次数:
56
详细讲解可以看这个 下面只是些模板 纯模板 int manacher() { // 将数组初始化 init(); int p[N*2],ans=0,mx=0,max_len=-1,id=0,index; // p[i]代表以i为中心的回文串半径,p[i]-1是以i为中心的最长回文串(相对于原字符串) ...
分类:
其他好文 时间:
2020-06-28 22:45:32
阅读次数:
63
方法一 暴力枚举所有可能的子数组,也就是枚举子数组的所有开始下标和结束下标,计算子数组的和,如果子数组的和小于等于s,就更新最小长度。 class Solution { public: int minSubArrayLen(int s, vector<int>& nums) { if(nums.si ...
分类:
编程语言 时间:
2020-06-28 20:34:15
阅读次数:
50
不用保证A>=B 大数乘小数 这里是把小数b当成一个整体来乘。 1 #include <bits/stdc++.h> 2 using namespace std; 3 vector<int> mul(vector<int> &A, int b) { 4 vector<int> C; 5 int t ...
分类:
其他好文 时间:
2020-06-28 18:34:34
阅读次数:
34
vector容器reserve函数的作用:减少vector在动态扩展容量时的扩展次数; //vector使用reserve预留空间,减少vector在动态扩展容量时的扩展次数 vector<T> v.reserve(int num); //num表示预留空间大小 vector容器内部维护的实际上是一 ...
分类:
其他好文 时间:
2020-06-28 12:46:24
阅读次数:
73
今天的题虽然简单,但是有个细节一定要注意,先放代码: 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 5 int main() { 6 int n = 0; 7 vector<int> num; //vector动态处 ...
分类:
其他好文 时间:
2020-06-28 09:28:34
阅读次数:
42
CCSU团队训练赛 总结:菜,菜在马力,菜在思维,菜在体力。 题目如下 A - Play the Dice 题意:掷骰子,给长度为n的数组指点数,每个被掷中概率为1/n,m个特殊骰子,掷中还能掷一次,求期望。 题解:水题,算出不能多掷的期望,与多掷一次的概率,联立方程直接搞。 代码部分 #inclu ...
分类:
其他好文 时间:
2020-06-28 00:36:07
阅读次数:
74
题目传送门 #Code #include<iostream> #include<cstdio> #include<string> #include<vector> #include<algorithm> #include<cstdlib> #include<cmath> #include<stack ...
分类:
其他好文 时间:
2020-06-27 20:05:01
阅读次数:
54