[atcoder 358] 【动态规划】
摘要: dp[i][j] 表示前i个和为j的个数。那么就有递推式dp[i][j] += dp[i][j-x] * c(j,j-x); 其中x满足从0到c[i],并且x满足<=j 组合数递推公式c(n,k) = c(n,k-1) + c(n,k); import java.io.BufferedReader;
30
0
0
[atcoder 357 题解]
摘要: https://zhuanlan.zhihu.com/p/702544612?
9
0
0
【leetcode 1510 石子游戏】【记忆化搜索】
摘要: 存在和对于一切的语言 import java.util.Arrays; class Solution { public boolean winnerSquareGame(int n) { dp = new Boolean[n + 1]; dp2 = new Boolean[n + 1]; Array
9
0
0
[leetcode 30 串联所有单词的子串 10ms]
摘要: 算法复杂度 o(1): 复杂最坏复杂度 是 o(s.length) 和 o(m*total)的最大值 码代码速度要变快,变量,算法要先想清楚 import java.util.*; class Solution { public List<Integer> findSubstring(String
4
0
0
[leetcode 3171] 解法列表
摘要: 线段树解法 + 二分 class Solution { public int minimumDifference(int[] nums, int k) { this.nums = nums; this.n = nums.length; return check(k); } public static
17
0
0
[leetcode 第 400 场周赛]题解
摘要: 第一题: class Solution { public int minimumChairs(String s) { int x = 0; int ans = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == 'E') { x-
5
0
0
[ 514. 自由之路] (动态规划)
摘要: dp[i][j] i 表示前i个字符 j 的选择是第i个字符在ring中出现的位置列表。给初始编号 dp[i][j] =. 所有(dp[i-1][k] + cost(j,k) k可选的这样的值中的最小值 import java.util.ArrayList; import java.util.Lis
5
0
0
【leetcode 找出第 K 大的异或坐标值]
摘要: 前缀和 + 最小堆 import java.util.PriorityQueue; class Solution { public static void main(String[] args) { Solution solution = new Solution(); solution.kthLa
5
0
0
【leetcode 399 周赛】【题解】
摘要: 第一题和第三题一样。就是求约数 第二题就是模拟 第4题使用线段树 1,3题代码 实际上发现没有下面代码复杂,比如: a*b = n ,枚举a就好,a在[1, sqrt(n)内。 import java.util.*; class Solution { public int numberOfPairs
15
0
0
【leetcode 3149. 找出分数最低的排列】记忆化搜索
摘要: 记忆化搜索 class Solution { public int[] findPermutation(int[] nums) { this.n = nums.length; this.nums = nums; dp = new int[n][1<<n]; for (int i = 0;i<n;i+
14
0
0
//雪花飘落效果
点击右上角即可分享
微信分享提示
深色
回顶
收起