04 2022 档案

摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e6 + 10; int a[N], q[N]; int main() { int n, k; scanf("%d %d", &n, &k); for (int i = 0; 阅读全文
posted @ 2022-04-30 17:02 wKingYu 阅读(31) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int stk[N], tt = 0; int main() { int n; scanf("%d", &n); while (n --) { int x; 阅读全文
posted @ 2022-04-30 16:14 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int q[N]; int l = 0, r = 0; void push(int x) { q[r] = x; r ++; } void pop() { l 阅读全文
posted @ 2022-04-30 00:37 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<stack> #include<cstring> #include<unordered_map> using namespace std; stack<int> nums; stack<char> op; unordered_ma 阅读全文
posted @ 2022-04-30 00:29 wKingYu 阅读(35) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int s[N], idx = 0; void push(int x) { s[idx] = x; idx ++; } void pop() { idx -- 阅读全文
posted @ 2022-04-29 23:26 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int e[N], r[N], l[N]; int idx; void init() { r[0] = 1; l[1] = 0; idx = 2; } voi 阅读全文
posted @ 2022-04-29 23:14 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int head, idx; int e[N], ne[N]; void init() { head = -1; idx = 0; } void add_to 阅读全文
posted @ 2022-04-28 11:09 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; typedef pair<int, int> PII; vector<PII> segs; void merge(vector<PI 阅读全文
posted @ 2022-04-27 22:44 wKingYu 阅读(55) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; typedef pair<int, int> PII; const int N = 3e5 + 10; vector<int> al 阅读全文
posted @ 2022-04-27 21:49 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; int lowbit(int x) { return x & -x; } int main() { int n; scanf("%d", &n); while (n --) { int x; scanf(" 阅读全文
posted @ 2022-04-27 16:57 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; 阅读全文
posted @ 2022-04-27 16:30 wKingYu 阅读(11) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; int main() { int n, m, x; scanf("%d %d %d", &n, &m, &x); for (i 阅读全文
posted @ 2022-04-27 16:15 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], s[N]; int main() { int n, res = 0; scanf("%d", &n); for (int i = 0; i 阅读全文
posted @ 2022-04-27 15:53 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e3 + 10; int a[N][N], b[N][N]; void insert(int x1, int y1, int x2, int y2, int c) { b[x1 阅读全文
posted @ 2022-04-26 22:10 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; void insert(int l, int r, int c) { b[l] += c; b[r + 1] -= c; } 阅读全文
posted @ 2022-04-26 21:39 wKingYu 阅读(19) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e3 + 10; int a[N][N], s[N][N]; int main() { int n, m, q; scanf("%d %d %d", &n, &m, &q); 阅读全文
posted @ 2022-04-26 21:10 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], s[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; 阅读全文
posted @ 2022-04-26 20:31 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; vector<int> div(vector<int>& A, int b, int &r) { vector<int> C; fo 阅读全文
posted @ 2022-04-25 21:57 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> using namespace std; vector<int> mul(vector<int>& A, int b) { vector<int> C; int t = 0; for (int i = 0; i < 阅读全文
posted @ 2022-04-25 21:21 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> using namespace std; bool cmp(vector<int>& A, vector<int>& B) { if (A.size() != B.size()) return A.size() > 阅读全文
posted @ 2022-04-25 21:04 wKingYu 阅读(28) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> using namespace std; vector<int> add(vector<int>& A, vector<int>& B) { vector<int> C; int t = 0; for (int i 阅读全文
posted @ 2022-04-25 20:12 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; int main() { double x; scanf("%lf", &x); double l = -1e5, r = 1e5; while (r - l > 1e-8) { double mid = 阅读全文
posted @ 2022-04-25 00:18 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N]; int main() { int n, k; scanf("%d %d", &n, &k); for (int i = 0; i < n; 阅读全文
posted @ 2022-04-25 00:03 wKingYu 阅读(36) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; typedef long long ll; const int N = 1e5 + 10; int a[N], tmp[N]; ll merge_sort(int l, int r) { if (l >= 阅读全文
posted @ 2022-04-24 17:36 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include <iostream> using namespace std; const int N = 1e6 + 10; int a[N], tmp[N]; void merge_sort(int l, int r) { if (l >= r) return; int mid 阅读全文
posted @ 2022-04-24 17:02 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N]; int quick_select(int l, int r, int k) { if (l >= r) return a[l]; int 阅读全文
posted @ 2022-04-23 23:16 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include <iostream> #include <algorithm> using namespace std; const int N = 1e5 + 10; struct Data { int x; double y; string z; bool operator< ( 阅读全文
posted @ 2022-04-23 22:59 wKingYu 阅读(39) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 class Solution { public: int NumberOf1(int n) { unsigned un = n; int res = 0; while (un) { res += un & 1; un >>= 1; } return res; } }; 首先将 n 转化 阅读全文
posted @ 2022-04-23 22:46 wKingYu 阅读(32) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 class Solution { public: vector<vector<int>> res; vector<vector<int>> permutation(vector<int>& nums) { sort(nums.begin(), nums.end()); do { res 阅读全文
posted @ 2022-04-23 22:42 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 class Solution { public: vector<int> findNumbersWithSum(vector<int>& nums, int target) { unordered_set<int> hash; for (int i = 0; i < nums.size 阅读全文
posted @ 2022-04-23 22:34 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:堆排序 点击查看代码 class Solution { public: vector<int> getLeastNumbers_Solution(vector<int> input, int k) { priority_queue<int> heap; for (auto x : input) { 阅读全文
posted @ 2022-04-23 17:54 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-23 17:44 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 class Solution { public: void reOrderArray(vector<int> &array) { int i = 0, j = array.size() - 1; while (i < j) { while (i <= j && array[i] % 2 阅读全文
posted @ 2022-04-23 17:41 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 class Solution { public: int getMissingNumber(vector<int>& nums) { if (nums.empty()) return 0; int l = 0, r = nums.size(); while (l < r) { int 阅读全文
posted @ 2022-04-23 13:00 wKingYu 阅读(22) 评论(0) 推荐(1) 编辑
摘要:![image](https://img2022.cnblogs.com/blog/2674359/202204/2674359-20220422225030033-1871223327.png) 阅读全文
posted @ 2022-04-22 22:51 wKingYu 阅读(21) 评论(0) 推荐(1) 编辑
摘要:可以用 if ( a.find(x) == a.end() ) 判断 x 在 a 中是否存在 阅读全文
posted @ 2022-04-22 22:19 wKingYu 阅读(12) 评论(0) 推荐(0) 编辑
摘要:![image](https://img2022.cnblogs.com/blog/2674359/202204/2674359-20220422220601594-1540187429.png) 阅读全文
posted @ 2022-04-22 22:06 wKingYu 阅读(13) 评论(0) 推荐(1) 编辑
摘要:在出栈时需要进行两步操作,即先 top( ) 获得栈顶元素,再 pop( ) 删除栈顶元素 阅读全文
posted @ 2022-04-22 21:49 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:![image](https://img2022.cnblogs.com/blog/2674359/202204/2674359-20220422213958989-1883945665.png) 阅读全文
posted @ 2022-04-22 21:41 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<vector> using namespace std; int main() { // 初始化 a 为 1, 2, 3 vector<int> a({1, 2, 3}); // 也可以是 vector<int> a {1, 2, 阅读全文
posted @ 2022-04-22 19:26 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-22 17:28 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-21 23:38 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:迭代版本 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; * 阅读全文
posted @ 2022-04-21 23:23 wKingYu 阅读(29) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 class Solution { public: int strToInt(string str) { int k = 0; while (k < str.size() && str[k] == ' ') k++; long long res = 0; int minus = 1; i 阅读全文
posted @ 2022-04-21 23:11 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-21 22:56 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-21 22:38 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; int n, m, ans = 0; void dfs(int x, int y) { if (x == n && y == m) ans ++; else { if (y < m) dfs(x, y + 阅读全文
posted @ 2022-04-15 23:07 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; int n, ans = 0; void f(int k) { if (k == n) ans ++; else if (k < n) { f(k + 1); f(k + 2); } } int main( 阅读全文
posted @ 2022-04-15 13:08 wKingYu 阅读(47) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 200; string str[N]; int n ; int main() { while (cin >> n, n) { int len = 1000; for (int i 阅读全文
posted @ 2022-04-15 10:57 wKingYu 阅读(113) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; string s, s1, s2; int main() { char c; while (cin >> c, c != ',') s += c; while (cin >> c, c != ',') s1 阅读全文
posted @ 2022-04-14 17:49 wKingYu 阅读(52) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; string str; int main() { while (cin >> str, str != ".") { int len = str.size(); for (int n = len; n; n- 阅读全文
posted @ 2022-04-14 16:59 wKingYu 阅读(97) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> #include<algorithm> using namespace std; string a, b; int main() { cin >> a >> b; if (a.size() < b.size()) swap(a, b); for ( 阅读全文
posted @ 2022-04-14 12:47 wKingYu 阅读(40) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; string str, res; int main() { while (cin >> str) { if (str.back() == '.') str.pop_back(); if (str.size( 阅读全文
posted @ 2022-04-14 12:09 wKingYu 阅读(24) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; string str; int n; int main() { cin >> n; while (n --) { cin >> str; int cnt = 0; char c; for (int i = 阅读全文
posted @ 2022-04-14 11:23 wKingYu 阅读(39) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> #include<sstream> using namespace std; string s, a ,b; int main() { getline(cin ,s); cin >> a >> b; stringstream ssin(s); st 阅读全文
posted @ 2022-04-14 10:41 wKingYu 阅读(32) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; string a, b; int main() { getline(cin, a); getline(cin, b); for (char& c : a) c = tolower(c); for (char 阅读全文
posted @ 2022-04-13 23:24 wKingYu 阅读(38) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 110; int n, m; int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; int x = 0, y = 0, d = 1, q 阅读全文
posted @ 2022-04-13 20:28 wKingYu 阅读(31) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e6 + 10; int n; int a[N]; void quick_sort(int l, int r) { if (l >= r) return; int i = l 阅读全文
posted @ 2022-04-13 15:13 wKingYu 阅读(26) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; int data1, data2, ans = 0, sum; int d[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; i 阅读全文
posted @ 2022-04-12 13:10 wKingYu 阅读(267) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int m, n, ans = 0; int lists[500]; int steps[25]; int machine[25][N]; int 阅读全文
posted @ 2022-04-10 15:24 wKingYu 阅读(196) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; long long n, m, total, sum1, sum2; int main() { cin >> n >> m; int min_mn = min(m ,n); for (int i 阅读全文
posted @ 2022-04-10 14:57 wKingYu 阅读(133) 评论(0) 推荐(0) 编辑

欢迎阅读『2022 年 4月 随笔档案』
点击右上角即可分享
微信分享提示