算法
爱做梦的阿彭
一分耕耘,一分收获
展开
-
快速幂汇总
快速幂算法(全网最详细地带你从零开始一步一步优化)原创 2021-10-25 13:42:50 · 127 阅读 · 0 评论 -
区间合并汇总
LeetCode专项练习之区间合并(Merge Interval)笔记原创 2021-10-25 13:29:43 · 138 阅读 · 0 评论 -
组合数汇总
DP:C++ 计算组合数(动态规划)递归:求组合数 C++程序C++组合数(combination)的实现// 计算组合数:使用动态规划算法 #include <iostream> int mat[100][100]; int combinat(int m, int n) { int i, j; if(n == 0 || m == n) return 1;// // 一行一行的计算下去// for(i = 1; i原创 2021-10-25 13:20:26 · 100 阅读 · 0 评论 -
全排列汇总
全排列算法-递归&字典序实现(Java)详解全排列c++中的全排列#include <iostream> #include <algorithm> using namespace std; int main() { int num[3]={1,2,3}; do { cout<<num[0]<<" "<<num[1]<<" "<<num[.原创 2021-10-25 09:59:20 · 58 阅读 · 0 评论 -
素数筛法汇总
https://www.luogu.com.cn/blog/Pluto1811/Sieve-of-Primehttps://www.freesion.com/article/38451197124/https://www.cnblogs.com/theshorekind/p/12690298.html原创 2021-10-25 09:48:15 · 60 阅读 · 0 评论 -
计数问题(数位DP)
计数问题(数位DP)https://blog.csdn.net/qiaoxinwei/article/details/110420115#include <iostream>#include <vector>using namespace std;//获取v中第l位到r位的数int get(vector<int> v, int l, int r){ int res = 0; for(int i = l; i >= r; i--)原创 2021-10-19 19:29:10 · 109 阅读 · 0 评论 -
大数乘法&&开根(C++)
大数乘法&&开根(C++)#include <iostream>#include <string>using namespace std; //两个字符串相乘 string strMultiply(string str1 , string str2){ string strResult = ""; int len1 = str1.length(); int len2 = str2.length(); int num[50原创 2021-10-19 18:52:17 · 581 阅读 · 1 评论 -
背包问题总结
背包问题背包问题是较为经典的动态规划问题,各种背包问题从简单到复杂,对于不同背包的状态转移方程,不仅记住,也要弄明白它们是怎么得出来的,最好能够自己想一种得到这些方程的方法。事实上,对每一道动态规划题目都思考其方程的意义以及如何得来,是加深对动态规划的理解、提高动态规划功力的好方法。01背包题目有NNN件物品和一个容量为VVV的背包。第i件物品的费用是w[i]w[i]w[i],价值是v[i]v[i]v[i],求将哪些物品装入背包可使价值总和最大。基本思路这是最基础的背包问题,特点是:每种物品仅有原创 2021-07-15 23:52:43 · 316 阅读 · 2 评论 -
最长上升子序列(LIS)
最长上升子序列(longest-increasing-subsequence)leetcode 300public class Solution { public int lengthOfLIS(int[] nums) { int len = nums.length; if (len <= 1) { return len; } // tail 数组的定义:长度为 i + 1 的上升子序列的末尾最小是几原创 2021-07-12 22:29:29 · 102 阅读 · 0 评论 -
最长公共子序列(LCS)
最长公共子序列(longest-common-subsequence)leetcode 1143class Solution { public int longestCommonSubsequence(String text1, String text2) { int m = text1.length(), n = text2.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 1;原创 2021-07-12 22:03:22 · 74 阅读 · 0 评论