上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页
摘要: #include <bits/stdc++.h> using namespace std; const int N = 100010; int h[N], e[N], w[N], ne[N], idx; int dist[N]; bool st[N]; int m, n; void add(int 阅读全文
posted @ 2020-08-12 19:53 Sexyomaru 阅读(108) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 550, M = 10010; struct Edges{int a, b, w;}edges[M]; int dist[N], pre[N]; int m, n, k; int 阅读全文
posted @ 2020-08-12 19:41 Sexyomaru 阅读(95) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 1000010; int h[N], e[N], ne[N], w[N], idx; int dist[N]; bool st[N]; int m, n; void add(int 阅读全文
posted @ 2020-08-12 19:28 Sexyomaru 阅读(115) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 550, M = 10010; int g[N][N], dist[N]; bool st[N]; int m, n; int dijkstra() { memset(dist,0 阅读全文
posted @ 2020-08-12 19:13 Sexyomaru 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 分析:将木棍的两个端点(0和n)加到cost数组中,dp[i][j]表示把这段木棍的第i到j个点完成切割的最小成本,i和j都是cost数组的下标。 状态计算: 最后的合并位置是k dp[i][j] = min(dp[i, k] + dp[k, j] + cost) class Solution { 阅读全文
posted @ 2020-08-10 19:48 Sexyomaru 阅读(452) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int maxNonOverlapping(int[] nums, int target) { int n = nums.length; int[] dp = new int[n+1]; // nums前i个数的最大满足条件子数组数目 Map<Inte 阅读全文
posted @ 2020-08-10 19:32 Sexyomaru 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 1540. K 次操作转变字符串 class Solution { public boolean canConvertString(String s, String t, int k) { if(s.length() != t.length()) return false; int n = s.le 阅读全文
posted @ 2020-08-10 19:29 Sexyomaru 阅读(120) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int countBinarySubstrings(String s) { int n = s.length(); int res = 0; int pre = 0, cur = 1; for(int i = 1; i < n; i++) { if(s 阅读全文
posted @ 2020-08-10 10:48 Sexyomaru 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 方法一:dfs class Solution { public boolean isHappy(int n) { dfs(n); return flag; } boolean flag = false; Set<Integer> set = new HashSet<>(); public void 阅读全文
posted @ 2020-08-07 17:06 Sexyomaru 阅读(71) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int rangeBitwiseAnd(int m, int n) { // 1.如果m与n二进制位数不同的话 由m到n每一位二进制位都出现过0,这里可以解释为: //由低位向高位进位时,低位会出现0,位数少的数所有位都会出现0 //比如从所有的三位二 阅读全文
posted @ 2020-08-07 16:05 Sexyomaru 阅读(133) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 15 下一页