随笔分类 - C/C++
摘要:概念 先版个板子 #include <bits/stdc++.h> using namespace std; class Matrix{ private: vector<vector<double>>a; public: void show(){ for(auto row:a){ for(auto
阅读全文
摘要:数论小结 03 欧拉函数的应用 RSA加密算法 选取两个质数 \(p,q\) 求 \(\varphi(n),n=p\cdot q\),显然:\(\varphi(n)=(p-1)(q-1)\) 构造公钥 \((n,e)\),选取 \(e\in[2,\varphi(n))\) 并且 \(\gcd(e,\
阅读全文
摘要:最小生成树 描述 输入:给出一个图(带权无向边集) 输出:给出一个最小生成树(带权无向边集) 测试数据 vector<Edge> edges={ Edge("A","I",6), Edge("A","J",6), Edge("A","G",5), //3 Edge("B","F",2), Edge(
阅读全文
摘要:数论小结 1. 扩展欧几里得 首先,根据辗转相除法,不难有: \[ \gcd(a,b)=\gcd(b,a\%b) \] 关于扩展欧几里得算法,是解决线性方程:\(ax+by=c\) 当且仅当,\(\gcd(a,b)|c\) 有解 又因为,\(x,y\in\Z\),所以问题可以转化为,解线性方程:\(
阅读全文
摘要:解题思路 思路显而易见,计算几何求凸包 Orz大佬,这Python代码绝绝子 @z1m 补充 2022/4/23 补充Graham算法 Andrew算法 C++版本 class Solution { public: vector<vector<int>> outerTrees(vector<vect
阅读全文
摘要:就是说不晓得为什么变量取名字还有重复的问题,不用取data,换成ss就过了 #include <bits/stdc++.h> using namespace std; set<pair<int,string> >ss; int getKey(string s){ int n=s.size(),cnt
阅读全文
摘要:template<typename T> class Queue{ private: vector<T>q; int size,top; public: Queue(){ top=0;q.clear(); } int getSize(){ return size; } bool empty(){ r
阅读全文
摘要:二分一个长度,(count)dis[n]<=k O(PlogNlogK) 1 #include <queue> 2 #include <iostream> 3 using namespace std; 4 const int INF=1e9,N=1e5+10; 5 struct edge { 6 i
阅读全文
摘要:有向图找环 1 #include<cstdio> 2 #include<cstring> 3 int map[27][27],indegree[27],q[27]; 4 int TopoSort(int n){ 5 int t=0,temp[27],p,m,flag=1; //flag=1:有序 f
阅读全文
摘要:题目大意: 有电器和配套的插座,以及每种无限个的装换插头 问:最少多少电器用不上电? 画画图,可以知道是一个二分图,中间结点需要用传递闭包优化掉 Floyd+匈牙利算法(二分图匹配) 1 #include<map> 2 #include<cmath> 3 #include<queue> 4 #inc
阅读全文
摘要:点权拆出来与0号点连边,按照下属→上级的方向建立有向图,跑一个s=0,t=1的单源最短路 限制条件:搜索到的最短路径中,阶级差不超过m 1 #include <queue> 2 #include <vector> 3 #include <cstring> 4 #include <iostream>
阅读全文
摘要:1 #include <bits/stdc++.h> 2 using namespace std; 3 long long n,x,t,m,k; 4 int main(){ 5 cin>>k; 6 while(k--){ 7 cin>>n>>x>>t; 8 m=min(t/x,n); 9 cout<
阅读全文
摘要:1 #include <stdio.h> 2 3 /*structure declaration*/ 4 struct employee{ 5 char *name; 6 int employee_id; 7 double salary; 8 }; 9 10 struct employee make
阅读全文
摘要:结构体自定义排序函数,调用stdlib.h库的系统快速排序qsort 1 //sjf non-preemptive with same arrival time 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 #define N 5010 6 7 struc
阅读全文
摘要:1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 typedef long long ll; 5 const int MAXN=1e5+10; 6 struct node{ll sum,add;}t[MAXN<<2]
阅读全文
摘要:1 #include<cstdio> 2 #include<cstring> 3 int map[27][27],indegree[27],q[27]; 4 int TopoSort(int n){ 5 int t=0,temp[27],p,m,flag=1; //flag=1:有序 flag=-1
阅读全文
摘要:就是秀一波操作辣 1 #include <iostream> 2 using namespace std; 3 const int N=1e3+20; 4 int ans[N],cnt=1; 5 struct heap{ 6 int a[N],n; 7 int top(){return a[1];}
阅读全文
摘要:呵呵,题目都这么明确了,题解什么的,就不需要了吧! 和上一篇poj2104的题意一模一样,数据范围*2了而已,可以直接复制代码过去a掉 但是我还是兢兢业业的重新敲了一遍,种树这种事情要勤奋嘛! 介于昨天刚学,自是不能领悟Insert操作的精妙之处 故今天写代码时先建了一颗nlogn的空树,方便查找(
阅读全文
摘要:主席树,大家这么叫的,也不知道为什么? 算法思路: 1.先排序,离散化 2.按排名插入n个版本的线段树 3.没有修改,查询即可 由于维护的是权值的区间和, 因此只要查询版本r和l-1,做差比较即可 1 #include <cstdio> 2 #include <algorithm> 3 using
阅读全文

浙公网安备 33010602011771号