摘要: 数学。 x^2 % n = 1 则 (x+1)(x-1) = kn. 设 x+1 = k1*n1, x-1=k2*n2。 则 k1*k2=k , n1*n2=n。 算出每个大于sqrt(n)的约数,然后分别作n1,n2尝试是否可行。 算x一定要取模。否则1会变成n+1。 #include #include #include #include #include using names... 阅读全文
posted @ 2016-06-25 22:58 invoid 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 费用流。 传说中建模之集大成之题。。。 https://www.byvoid.com/blog/noi-2008-employee 题解 题解里面关于建模已经讲的很全了。 我根据自己的理解写写建模的实际意义。 如果a[i]-a[i-1]>=0,代表需要新雇佣人。否则就代表有人离开了。(离开并不一定要在t[i]+1天,如果后面人多余的话,很早就会离开)。 1.建模为S->i容量为 a[i... 阅读全文
posted @ 2016-06-25 13:50 invoid 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 水题。 按位处理,复杂度O(nlogm)。真心好看。。。。。 #include #include #include using namespace std; const int maxn = 100000 + 10; int n,m,k,l,f1,f2,res; char s[20]; int op[maxn],t[maxn]; inline int calc(int f,int i... 阅读全文
posted @ 2016-06-25 09:39 invoid 阅读(150) 评论(0) 推荐(0) 编辑
摘要: splay. 就是splay,没别的了。 #include #include #include using namespace std; const int maxn = 600000 + 10; const int inf = 0x3f3f3f3f; struct Splay { int v[maxn],s[maxn],sum[maxn]; int l[maxn],r... 阅读全文
posted @ 2016-06-25 09:07 invoid 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 状态压缩dp。 一道很好的dp题。 我们在选的时候并不知道它会对后面的选择造成什么影响,所以不能正向dp。 f[i][s]表示第i次选择后,选择的宝物二进制为s的期望得分。 初始状态均为0,答案为f[0][0]。 #include #include #include using namespace std; const int maxn = 20; const int maxm =... 阅读全文
posted @ 2016-06-25 08:59 invoid 阅读(133) 评论(0) 推荐(0) 编辑