- 博客(29)
- 收藏
- 关注
原创 LeetCode 879 Profitable Schemes
There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can’t participate in another crime.Le
2021-03-13 15:23:03 132
原创 子字符串匹配
子字符串匹配给定两个字符串s和t,其中t是s的子字符串,s的子字符串是字符串都取自s,并且保持在s的位置的相对顺序,但不需要是连续的。比如,s="abcdef", t="bd"要求找出t在s中匹配的字符串数量Input: s="rabbbit" t="rabbit"Output:3题解这道题类似于求最长公共子序列(lcs)类似:不需要连续,只需要相对顺序相同不同:lcs是子序列不确定,找相同序列的最长长度;此题是子序列已定,母串必须包括字串的全部,问的是个数lcs/** *
2021-03-10 23:09:54 552
原创 04: Median of Two Sorted Arrays
Median of Two Sorted ArraysGiven two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.Example 1:Input: nums1 = [1,3], nums2 = [2]Output: 2.00000Explanation: merged array = [1,2,3] and median is
2021-03-04 15:17:41 125 1
原创 LeetCode 3 Longest Substring Without Repeating Characters
Given a string s, find the length of the longest substring without repeating characters.Example 1:Input: s = "abcabcbb"Output: 3Explanation: The answer is "abc", with the length of 3.Example 2:Input: s = "bbbbb"Output: 1Explanation: The answe
2021-03-02 23:39:31 94
转载 深入理解Mybatis插件开发
阅读目录背景Mybatis插件典型适用场景Mybatis插件介绍Mybatis插件实现机制Mybatis插件开发例子小结背景关于Mybatis插件,大部分人都知道,也都使用过,但很多时候,我们仅仅是停留在表面上,知道Mybatis插件可以在DAO层进行拦截,如打印执行的SQL语句日志,做一些权限控制,分页等功能;但对其内部实现机制,涉及的软件设计模式,编程思想往往没有深入的理解。本篇案例将帮助读者对Mybatis插件的使用场景,实现机制,以及其中涉及的编程思想进行一个小结,希望对以后的
2021-01-19 14:43:21 88
原创 LeetCode 15. 3Sum
class Solution { public List<List<Integer>> threeSum(int[] nums) { ArrayList<List<Integer>> res = new ArrayList<>(); sort(nums); for(int i = 0...
2020-02-18 14:17:35 99
原创 LeetCode 02.Add Two Numbers
#include <stdio.h>#include <malloc.h>#include <stdlib.h>typedef struct Node { int data; Node *next;}ListNode, *List;List Convert(int a){ ListNode *p, *tail; L...
2020-02-10 12:42:31 83
原创 hdu2059
#include <bits/stdc++.h>using namespace std;const int INF = 0x3f3f3f3f;double dp[150] = {0};int p[105] = {0};int n, c, t;int vr, vt1, vt2;double tr;int l;int main(){ while(~scanf...
2020-02-05 19:13:17 181
原创 hdu2058
#include <stdio.h>#include <math.h>int main(){ int N, M; while(scanf("%d%d", &N, &M)) { if(N == 0 && M == 0) break; int an = (int)sqrt(M*2.0); ...
2020-01-27 15:32:27 108
原创 hdu2057
第一种#include <stdio.h>void print(long long n) //10# --> 16#{ int a[20]; int flag = 0; if(n < 0) {flag = 1; n = -n;} if(n == 0) printf("0"); int i = 0; while(n !=...
2020-01-27 13:42:13 332
原创 hdu2055
#include <cstdio>int main(){ int t; char ch; int a; scanf("%d", &t); getchar(); while(t--) { scanf("%c%d", &ch, &a); if(ch >= 'a' &&...
2020-01-18 13:31:21 315
原创 hdu2053
#include <cstdio>#include <cmath>using namespace std;bool isInt(double x){ long int y=(long int) x; //if ((x-y)!=0)//这段代码可能会丢失精度 if((x-y)<=0.0000001&&(x-y)>=-...
2020-01-17 15:54:32 117
原创 hdu2049
#include <stdio.h>long long f[25] = {0, 0, 1};long long a[25][25];int fun(){ for(int i = 3; i <= 20; i++) f[i] = (i - 1)*(f[i - 1] + f[i - 2]);}int sum(){ for(int i =...
2020-01-06 15:38:54 602
原创 hdu2048
#include <stdio.h>long long a[25] = {0, 0, 1};long long f[25] = {0, 1};void fun(){ for(int i = 3; i <= 20; i++) a[i] = (i - 1)*a[i - 1] + (i - 1)*a[i - 2];}void sum(){ ...
2020-01-02 16:29:10 891 1
原创 hdu2047
#include <stdio.h>long long a[45] = {0, 2}, b[45] = {0, 1}, t[45] = {0, 3};void fun(){ for(int i = 2; i <= 40; i++) { a[i] = (a[i - 1] + b[i - 1])*2; b[i] = a[i - ...
2020-01-01 15:08:44 177
原创 hdu2046
#include <stdio.h>long long a[55] = {0, 1, 2};void fun(){ for(int i = 3; i <= 50; i++) a[i] = a[i - 1] + a[i - 2];}int main(){ fun(); int N; while(scanf("%d", &...
2020-01-01 13:32:34 189
原创 hdu2045
#include <stdio.h>long long a[55] = {0, 3, 6, 6};void fun(){ for(int i = 4; i <= 50; i++) a[i] = a[i - 1] + a[i - 2]*2;}int main(){ fun(); int N; while(scanf("%...
2020-01-01 12:52:31 128
原创 hdu044
#include <stdio.h>long long t[55]; int fun(){ t[1] = 1, t[2] = 2; for(int i = 3; i <=50; i++) t[i] = t[i - 1] + t[i - 2];}int main(){ int N; int a, b; fu...
2019-12-30 15:52:03 124
原创 hdu 2036
#include <stdio.h>struct Node{ int x, y;}node[105];//(x0,y0), (x1,y1), (x2, y2)是逆时针返回值为正,顺时针返回值为负double proportion(Node a, Node b, Node c){ return 0.5*(a.x*b.y + b.x*c.y + c.x*a.y...
2019-12-30 13:25:17 116
原创 hdu2034
#include <stdio.h>int getIndex(int a[], int low, int high){ int tmp = a[low]; while(low < high) { while(low < high && a[high] >= tmp) high--; ...
2019-12-28 23:58:24 312
原创 hdu 2030
#include <stdio.h>int length(char a[]) //要善用指针{ char *ch = a; int c = 0; while(*ch != '\0') { c++; ch++; } return c;}int main(){ int n; ch...
2019-12-27 22:25:12 82
原创 hdu2029
#include <stdio.h>int length(char a[]) //要善用指针{ char *ch = a; int c = 0; while(*ch != '\0') { c++; ch++; } return c;}bool judge(char a[], int n){ ...
2019-12-26 16:22:48 165
原创 hdu2028
#include <stdio.h>int gcd(int a, int b) //辗转相除法求得最大公约数{ if(a == 0) return b; else return gcd(b % a, a);}int Sort(int a[], int n) //冒泡排序{ for(int i = 0; i &l...
2019-12-26 15:38:57 222
原创 hdu2021
#include <stdio.h>int a[10] = {100, 50, 10, 5, 2, 1};int fun(int t){ int cnt = 0, i; for(i = 0; i < 6; i++) { if(t >= a[i]) { cnt += t / a[i]; t ...
2019-12-25 13:18:17 149
原创 hdu2014
#include <stdio.h>int a[35];int cal(int n) //记忆化{ a[n] = 1; for(int i = n - 1; i >= 1; i--) a[i] = (a[i + 1] + 1) * 2;}int cal2(int n) //递推{ if(n == 1) r...
2019-12-25 10:03:15 104
原创 hdu2012
#include <stdio.h>#include <math.h>int cal(int x){ return x*x + x + 41;}bool isPrime(int x){ int flag = 1; for(int i = 2; i <= sqrt(x); i++) { if(x % i == 0) { flag = 0...
2019-12-24 16:23:49 79
原创 hdu2000 ASCII码排序
#include <stdio.h>void sortAscll(char &a, char &b){ char tmp; if(a > b) { tmp = a; a = b; b = tmp; }}int main(){ char a, b, c; w...
2019-12-23 22:30:20 94
转载 大佬orz
屏幕在深夜微微发亮思想在那虚树路径上彷徨平面的向量交错生长织成 忧伤的网剪枝剪去我们的疯狂SPFA告诉我前途在何方01背包装下了忧伤笑颜 洋溢脸庞键盘微凉 鼠标微凉指尖流淌 代码千行凸包周长 直径多长一进考场 全都忘光你在OJ上提交了千百遍却依然不能卡进那时限双手敲尽代码也敲尽岁月只有我一人 写的题解凋零在OJ里面tarjan陪伴强联通分量生成树完成后思路才闪光...
2018-04-25 16:11:27 133
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人