原创 strcpy,strcat,strcmp(字符串基礎)

strcpy將一個字符串覆蓋到另一個字符串 #include<cstdio> #include<cstring> //strcpy的作用以及用法 int main(){ char a[32]="Hello"; ch

原创 並查集

初始化 for(int i=0;i<n;i++) { pre[i]=i; } 查找 int find(int x) { if(x==pre[x]) return x; return fin

原创 cantor表

添加鏈接描述

原创 兔子與兔子(字符串hash)

傳送門 很久很久以前,森林裏住着一羣兔子。 有一天,兔子們想要研究自己的 DNA 序列。 我們首先選取一個好長好長的 DNA 序列(小兔子是外星生物,DNA 序列可能包含 26 個小寫英文字母)。 然後我們每次選擇兩個區間,詢問如

原创 全排列

next_permutation() 增序不重複 #include <bits/stdc++.h> #include <algorithm>//next_permutation()的使用 頭文件 using namespace s

原创 前綴和 差分

前綴和 已知a[n],ma[n],ma[n],m次詢問,求[l,r][l,r][l,r]區間裏的數的和 int a[0]=0; for(int i=1;i<=n;i++) a[i]+=a[i+1]; 計算**a[r]-a[l-1

原创 Tarjan

#include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; vector<int> G[maxn]; int DFN[maxn], L

原创 角度與多邊形

傳送門 #include <bits/stdc++.h> using namespace std; int t,ang; int main() { cin >> t; while(t--) {

原创 中位數

一個有 n 個整數的數組 a,n是一個奇數。 每次可以選擇數組裏的一個元素 a​i ​​ 並把這個元素加上 1。 在至多 k 次操作之後,數組的中位數最大能變成多少。 輸入格式: 多組輸入 第一行兩個整數 n,k(1≤n≤2×1

原创 貪心算法

給定一個字符串類型的數組strs,找到一種拼接方式,使得把所有字符串拼起來之後形成的字符串具有最低的字典序。 #include <iostream> #include <cstring> #include <vector> #in

原创 計算數列

添加鏈接描述 #include <bits/stdc++.h> using namespace std; #define int long long int n,x,ans,s; const int mod = 998244353

原创 優先隊列

添加鏈接描述 #include<bits/stdc++.h> #define int long long using namespace std; priority_queue<int,vector<int>,less<int>

原创 計算器的改良

傳送門添加鏈接描述 #include<cstdio> #include<cstring> using namespace std; double num=0,x=0;//num是數字之和,x爲係數之和 char c,p;//c被

原创 多項式輸出

傳送門添加鏈接描述 #include <iostream> #include <cmath> using namespace std; int main() { int n; cin >> n; for(i

原创 記憶化搜索

傳送門添加鏈接描述 #include <bits/stdc++.h> using namespace std; int r[22][22][22]; int w(int a,int b,int c) { if(a<=0||