上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: #include #include #include #include #include #include using namespace std; int n,m,k,ans,cnt,head[1001],vis[1001],match[1001]; struct uio{ int next,to; }edge[1000001]; int add(int x,int y) { ... 阅读全文
posted @ 2018-07-08 17:11 radishえらい 阅读(132) 评论(0) 推荐(0)
摘要: //二叉查找树 //特点:每个点左子树上的点都小于该点,右子树上的点都大于该点 //没有取值相同的点 任意点的左右子树均为二叉查找树 //中序遍历严格单调递增 #include #include #include #include #include #include using namespace std; struct uio{ int num,cnt,dfs;//num取值 ... 阅读全文
posted @ 2018-07-08 17:10 radishえらい 阅读(116) 评论(0) 推荐(0)
摘要: //单调队列 //队列元素递增或递减 元素最多进队出队各一次 //应用:复杂度为o(n^2)的动态规划 可求最大最小值 #include #include #include #include #include #include using namespace std; int n,m,a[1000001]; struct uio{ int minum,micnt; }mi[1000... 阅读全文
posted @ 2018-07-08 17:09 radishえらい 阅读(132) 评论(0) 推荐(0)
摘要: //大步小步算法 BSGS //对于式子 x^y=z mod p 已知x,z和p可求y //由于费马小定理 y的取值范围为[0,p-1] //利用分块思想 将y分为a*m+b m=sqrt(p-1) //其中x^b预处理存在Hash中 枚举a即可 #include #include #include #include #include #include #include #define... 阅读全文
posted @ 2018-07-08 17:08 radishえらい 阅读(244) 评论(0) 推荐(0)
摘要: #include #include #include #define maxn 105 #define INF 0x3f3f3f3f using namespace std; int head[maxn],maxcost[maxn][maxn],map[maxn][maxn]; bool used[maxn][maxn];//m int n,m,t,cnt,x,y,z,vis[maxn],d... 阅读全文
posted @ 2018-07-08 17:00 radishえらい 阅读(105) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #define ll long long using namespace std; ll n,p; void exgcd(ll a,ll b,ll &x,ll &y) { if(!b) { x=1;y=0; return; } ... 阅读全文
posted @ 2018-07-08 17:00 radishえらい 阅读(161) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #define ll long long using namespace std; ll n,p,a[3000001]; int main() { scanf("%lld%lld",&n,&p); a[1]=1; printf("%lld\n",a[1]); ... 阅读全文
posted @ 2018-07-08 16:59 radishえらい 阅读(146) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #define ll long long using namespace std; ll n,p; int main() { scanf("%lld%lld",&n,&p); ll a=n,ans=1,b=p-2; while(b) { if... 阅读全文
posted @ 2018-07-08 16:59 radishえらい 阅读(146) 评论(0) 推荐(0)
摘要: //带偏移量的并查集≈并查集补集 //维护各点到父节点的距离 可用来分类 #include #include #include #include #include #include using namespace std; int n,f[1001],d[1001]; int find(int x) { if(x==f[x]) return x; d[x]+=... 阅读全文
posted @ 2018-07-08 16:58 radishえらい 阅读(287) 评论(0) 推荐(0)
摘要: //Tarjan 强连通分量 //dfn[]时间戳 low[]经过一条非回溯边可到达的时间戳最小节点 即其能回溯到的最小节点 #include #include #include #include #include #include using namespace std; int n,m,cnt,head[10001]; int t,sta[10001],vis[10001]; int d... 阅读全文
posted @ 2018-07-08 16:55 radishえらい 阅读(130) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 下一页