
动态规划
小明的博客
acm小弟
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leecode<每日一题>学生出勤记录 II
Leecode<每日一题>学生出勤记录 II题目链接思路:动态规划,dp[i][0],表示n == i,缺勤次数为0时的可能情况数。dp[i][1],表示n == i,缺勤次数为1时的可能情况数。class Solution {public: int checkRecord(int n) { long long dp[100010][2]{}; dp[1][0] = 2,dp[1][1] = 1; dp[2][0] = 4,dp[2][1]原创 2021-08-17 10:59:40 · 317 阅读 · 0 评论 -
Leecode<每日一题>出界的路径数
Leecode<每日一题>出界的路径数题目链接思路:动态规划,dp[i][j][step] 表示在位置[i,j]处,可移动距离为step时,出界的路径数。class Solution {public:int dp[51][51][51]{};vector<vector<int>> dir= { {1,0},{-1,0},{0,1},{0,-1} }; int findPaths(int m, int n, int maxMove, int startRow, i原创 2021-08-15 15:49:46 · 224 阅读 · 0 评论 -
Leecode<每日一题>最长回文子序列
Leecode<每日一题>最长回文子序列题目链接思路:动态规划dp[i][j]表示下标i到j的区间内,最大的回文子序列的长度。动态转移方程:dp[i][end] = dp[i + 1][end - 1] + 2; //区间首位相同的转移方程dp[i][end] = max(dp[i][end - 1],dp[i+1][end]); //区间首位不同的转移方程class Solution {public: int longestPalindromeSubseq(string s原创 2021-08-12 10:38:56 · 231 阅读 · 0 评论 -
Leecode<每日一题>等差数列划分 II - 子序列
Leecode<每日一题>等差数列划分 II - 子序列题目链接思路:动态规划+哈希表class Solution {public:typedef long long ll; int numberOfArithmeticSlices(vector<int>& nums) { auto tab = vector<unordered_map<int, int>>(nums.size() + 1); int sum = 0; for (int原创 2021-08-11 10:37:05 · 189 阅读 · 0 评论 -
网易笔试题-双核处理
#include"stdio.h"#include"algorithm"#include"iostream"#include"math.h"#include"string.h"using namespace std;int f[51][40000];int main(){ memset(f, 0, sizeof(f)); int N; int ai[51],b原创 2017-03-25 16:31:14 · 3022 阅读 · 1 评论 -
牧场物语
题目网址:http://acm.fzu.edu.cn/problem.php?pid=2234#include"stdio.h"_int64 dp[105][105][200];_int64 max(_int64 a,_int64 b){ return a>=b?a:b;}int main(){ _int64 const min=1e18; int i,j,k,n原创 2017-03-26 17:12:16 · 2625 阅读 · 0 评论 -
And Then There Was One
Let’s play a stone removing game. Initially, n stones are arranged on a circle and numbered 1,…,n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one原创 2017-04-21 17:26:16 · 2563 阅读 · 0 评论