#include<iostream>
#include<cstring>
using namespace std;
const int N = 20010;
const int M = 200010;
int h[N], e[M], next_pos[M]...
#include<iostream>
#include <string>
using namespace std;
class Base
{
public:
string content;
Base(string c)
{ conten...
二分图等价定义:不含奇数条边的环。
染色法:
(1)dfs,链式前向星
#include<iostream>
using namespace std;
const int N = 1010;
int h[N], e[N], next_pos[N], n,...
Description:一棵树,添加k条边使得遍历所有的点的总代价最小,其中1<=k<=2;
不建道路,路线总长度2*(n-1);
当k等于1,此时的最优解无疑是将边加到直径两端;那么答案就是2*(n-1)-d+1;其实考虑k=2时,对于一棵树,我们加边会形成一个环,加...
#include<iostream>
using namespace std;
int days[] = {0, 30, 31, 30, 31, 31, 30, 31, 30, 31};//4月之后每月的天数,第一个元素为0便于计数
string week[] =...
树的直径:树中所有最短路径的最大值。(1)树状dp(得到直径值);(2)若无负权边,2次DFS(BFS)得到直径值和最长链)
(1)在一个连通无向无环图中,以任意结点出发所能到达的最远结点,一定是该图直径的端点之一。
(2)树的直径,等于以树直径上任意一点为根的有根树,其左子树的高...
(1)最短路径树和最小生成树的区别:
最短路径树:源点到其它所有节点的最短路径构成的树。实际上是一个(DAG)
最小生成树:网络中任意两个顶点可达,且边集总长度最小,不能保证源点到其它点距离最小。
(2)求最短路径树的数量:乘法原理(记录每个节点的父节点可取数cnt[i]表示...
度受限的最小生成树:
给定一张N个点,M个边的无向图,求出无向图的一颗最小生成树,但是我们要求一号节点的入度不可以超过给定的整数S
也就是一个最小生成树,要求它的一号节点,最多只能和S个节点相连.
————&mdas...
dfs
应用:求最小生成树某一结点到其它各节点的路径上的最大边
#include<iostream>
using namespace std;
const int N = 100;
int n, m;
bool vis[N][N]; int g[N][N];...
并查集
将边升序排列,两个连通图之间增加(p*q-1)条边,最小增加的权值为(w+1)。
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 6010;...
https://blog.csdn.net/sugarbliss/article/details/86551050
拼尽全力,青春无悔!
在路上就是最好的状态,加油,结果不负有心人!
整除#include<bits/stdc++.h>
using namespace std;
int main(){
int count=0;
for(int i=100;i<=1000;i+...
#include <bits/stdc++.h>
C++语言中反转字符串的函数strrev(), reverse()
1:
char s[]="hello";
strrev(s);
puts(s);
return 0;
2:
...
#include <bits/stdc++.h>
using namespace std;
int main(){
int a[11];
int t;
 ...
01序列:
#include
using namespace std;
int main()
{
for(int i=0;i<64;i++)
{
int a[6]={0};//先将数组全置为0
int k=i;将k置为i,随着循环...
第一个简单模拟(万能头文件#include<bits/stdc++.h>其下面也可以编辑C语言)
一般C++头文件(#include <iostream>
&n...
1.字符串分割
String[] subStr=str.split(":");
例如:12:30
String[0]=12 String[1]=30
2.String.format("%02d...
结构体变量占据的空间大小会对齐,整体的大小是最大的成员变量的整倍数。
尚有疑问的题,在此记录一下,
1472 通过80%
1221 输出超限。
#include
#include
int a[101]={0};
int main()
{
int i,c,b;
scanf("%d",&b);
for(int i=0;i0){
printf("...
char str[6];
int L=66;
sprintf(str,"%d",L);
最近发现少部分同学们学习进入了误区,机试是一门实践性很强的科目。就好比大家小时候学习练字一样,刚开始我们都需要一套书法进行临摹,照着别人的字进行模仿,不断写直到把常用的字都熟练为止。而有少部分同学练第一个字就开始迷糊,今天学习了楷书的这个字,明天看到草书的这个字又跑...
1.题目中12的阶乘非零数位为6,应该是5才对吧
2.麻烦大佬帮我看一看我的代码哪里错了,输入12是5,但输入10000000为0????
#include <iostream>
using namespace std;
int main()
{
&...
这是行内嵌入公式$\surd, \sqrt{2}, \sqrt[n]{}, \sqrt[3]{\frac{x^3+y^3}{2}}$ ,文字和公式在同一行。
使用 $$1+1=2$$ 渲染时公式另起一行。
不换行两边用单个$包围,将latex公式放在中间
换行...
冒泡排序
思想:把任意两个相邻的大小相反的位置交换、最多进行N趟、
复杂度O(n^2)
#include <cstdio>
#include <cstring>
#include <algorithm>
using n...