摘要: 新Link: mczhuang.cn 阅读全文
posted @ 2017-10-27 07:47 Michael_Zhuang 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 做法:快速幂+求逆元取模 因为ans=((3^(n+2))/2)%P 而ans%P/2!=ans/2%P 所以由费马小定理当gcd(a,p)==1&&P为质数时,a^(p-1)≡1(mod p)可得:ans*(p+1)/2≡ans/2 (%p) 然后就可以美滋滋地对ans取模辣 Code: 1 #i 阅读全文
posted @ 2017-10-26 20:13 Michael_Zhuang 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 做法:斜率优化DP 斜率优化DP:Link 预处理:sort处理可合并土地,得到a[]严格上升,b[]严格下降的序列 朴素DP方程:F[i]=min f[j]+a[i]*b[j+1](0<j<i) 朴素DP Code: 1 #include <cstdio> 2 #include <cstring> 阅读全文
posted @ 2017-10-26 10:13 Michael_Zhuang 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 线段树维护sum值并记录add与mult用于标记下传+乘法结合律 1 #include <cstdio> 2 #define ll long long 3 inline int read() 4 { 5 register int k=0,f=1;register char c=getchar(); 阅读全文
posted @ 2017-10-23 19:39 Michael_Zhuang 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Solution: Kruskal+并查集+暴搜 对于每一个符合题意的最小生成树,其每一条树边必定满足:①边权值和一定②对于最小生成树上的每一种权值的边,其数量一定 利用条件②,可以在每一种权值中dfs枚举所有情况,利用并查集判断待取边能否加入(因为回溯需要恢复状态,不能路径压缩) Code: 1 阅读全文
posted @ 2017-10-19 21:36 Michael_Zhuang 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 1666: [Usaco2006 Oct]Another Cow Number Game 奶牛的数字游戏 模拟 1 #include <cstdio> 2 inline int read() 3 { 4 register int f=1,c=getchar(),k=0; 5 while (c<'0' 阅读全文
posted @ 2017-10-18 19:57 Michael_Zhuang 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Solution:最短路树+并查集/树链剖分维护 1 #include <cstdio> 2 #include <queue> 3 #include <algorithm> 4 inline void swap(int &a,int &b) 5 { 6 register int tmp=b; 7 b 阅读全文
posted @ 2017-10-18 19:30 Michael_Zhuang 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Re 【问题引入】 对于区间修改、区间查询这样的简单问题,打一大堆线段树确实是不划算,今天来介绍一下区间查询+区间修改的树状数组 【一些基础】 树状数组的基本知识不再介绍,请自行百度 我们假设sigma(r,i)表示r数组的前i项和,调用一次的复杂度是log2(i) 设原数组是a[n],差分数组c[ 阅读全文
posted @ 2017-10-13 19:53 Michael_Zhuang 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 1 #include<bits/stdc++.h> 2 const int RN=1e5; 3 char ib[RN+5],*ip=ib+RN,ob[RN+1007],*op=ob; 4 inline int gc(){ 5 ip==ib+RN?fread(ip=ib,1,RN,stdin)[ib] 阅读全文
posted @ 2017-10-10 21:42 Michael_Zhuang 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Notes:莫名其妙WA一定是数组开小了!!! 一句话树链剖分:将一棵树“剖分”为多条链再映射到线段树上维护 时间复杂度:O(n(logn)^2) BZOJ 1036题意: 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w。我们将以下面的形式来要求你对这棵树完成一些操作: I. CHAN 阅读全文
posted @ 2017-10-10 21:37 Michael_Zhuang 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Q1: http://codevs.cn/problem/1081/ 1:给区间[a,b]的所有数都增加X 2:询问第i个数是什么? 1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 using namespace std; 阅读全文
posted @ 2017-09-19 19:00 Michael_Zhuang 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 第一题 题意 数据范围 Solution 三分求下凹函数最值 1 #include <cstdio> 2 #include <queue> 3 #include <iostream> 4 using namespace std; 5 inline void read(int &k) 6 { 7 k= 阅读全文
posted @ 2017-09-14 19:49 Michael_Zhuang 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 题意 Solution 压位+前缀和 1 #include <cstdio> 2 #include <iostream> 3 #include <cmath> 4 #include <algorithm> 5 #define ll int 6 using namespace std; 7 const 阅读全文
posted @ 2017-09-11 19:23 Michael_Zhuang 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题意 给你一棵带边权的树,然后这棵树是某个完全图唯一的最小生成树。问原来的完全图中所有边可能的最小边权和是多少。完全图是任意两个点之间都有边相连的图。 Solution O(n^3)算法:kruskal 逆推枚举+并查集 O(n):带权并查集+sort 1 #include <iostream> 2 阅读全文
posted @ 2017-09-08 19:40 Michael_Zhuang 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 第一题 直接贴Code: 1 #include <cstdio> 2 int min(int a,int b) 3 { 4 return a<b?a:b; 5 } 6 using namespace std; 7 int main() 8 { 9 int n,a1,a2,b1,b2,c1,c2,an 阅读全文
posted @ 2017-08-13 07:51 Michael_Zhuang 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 强连通 Tarjan 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #define ll long long 5 struct node{ 6 ll next,v; 7 }edge[1001]; 8 const 阅读全文
posted @ 2017-08-11 16:44 Michael_Zhuang 阅读(176) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-08-10 20:50 Michael_Zhuang 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 初二学完忘了QAQ,今天再学一发 原题Link:https://www.luogu.org/problem/show?pid=3379 Code: 1 #include <iostream> 2 #include <cstdio> 3 const int maxn=500000*2+100; 4 i 阅读全文
posted @ 2017-08-10 16:29 Michael_Zhuang 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 难度区间:NOIP提高- 第一题 题意: 滚来滚去 Solution 刚开始写了O(n)的60分模拟,打了1h的状态表,结果写砸了只剩35分QAQ 对于30%的数据:O(n^2)模拟 对于60%的数据:O(1)求横向翻转,O(n)模拟向下翻转的情况 对于100%的数据:时间复杂度:O(1) 分类讨论 阅读全文
posted @ 2017-08-08 21:36 Michael_Zhuang 阅读(115) 评论(0) 推荐(0) 编辑
摘要: OI Trainning 知识体系结构 From:http://www.cnblogs.com/hadilo/p/5840434.html 初级 1.1 C语言基础 1.1.1 C语言程序结构(A+B Problem) 1.1.2 变量,常量,数据类型,输入与输出 1.1.3 条件语句 1.1.4 阅读全文
posted @ 2017-07-15 11:53 Michael_Zhuang 阅读(228) 评论(0) 推荐(0) 编辑
摘要: (CodeVS:1082) C++指针版 指针+读入优化 数组模拟+读入优化 阅读全文
posted @ 2017-07-06 12:16 Michael_Zhuang 阅读(96) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-07-01 20:44 Michael_Zhuang 阅读(1) 评论(0) 推荐(0) 编辑
摘要: KMP var p,t:string; f:Array[0..255] of longint; m,n,i,j:longint; procedure getfail; begin f[1]:=1;f[2]:=1; for i:=2 to m do begin j:=f[i]; while (j>1) 阅读全文
posted @ 2017-06-29 11:44 Michael_Zhuang 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 预计学习时间Total:50days details: 8:00-8:30东方某神奇巨著 8:50-11:00 数据结构/算法 11:30-12:00 英语单词/unit+refresh 3:00-6:00 BZOJ 8:00-10:30 比赛/Blog update Goals: 高考单词:all 阅读全文
posted @ 2017-06-29 11:31 Michael_Zhuang 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 简单链表输入输出: 阅读全文
posted @ 2017-06-29 11:25 Michael_Zhuang 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2017-06-28 09:50 Michael_Zhuang 阅读(147) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-06-28 09:13 Michael_Zhuang 阅读(15) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; int a,b; long long qp(int a,int b) { int t=1;int y=a; while (b) { if (b&1) t=t*y;//whether odd or not y=y*y; b=b>>1; ... 阅读全文
posted @ 2017-06-27 15:49 Michael_Zhuang 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Code: Re: Kruskal 水题一枚,初转CPP练练手 (PS:类似HF奥考机试第二题,然而我并没有看粗来,果然是蒟蒻Orz) 阅读全文
posted @ 2017-06-27 15:02 Michael_Zhuang 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 开始转cpp 阅读全文
posted @ 2017-06-27 09:24 Michael_Zhuang 阅读(117) 评论(0) 推荐(0) 编辑