链接:https://ac.nowcoder.com/acm/contest/881/B 来源:牛客网 Integration 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Bobo knows that ∫ ∞ 0 1 1 x 2 d x = π 2 . ∫0∞11+x2 dx=π2. Given n distinct positive integers a 1 , a 2 , -…
链接:https://ac.nowcoder.com/acm/contest/882/F来源:牛客网 Given 2N people, you need to assign each of them into either red team or white team such that each team consists of exactly N people and the total competitive value is maximized. Total competitive va…
链接:https://ac.nowcoder.com/acm/contest/881/A来源:牛客网 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r)RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1≤l≤r≤m where RMQ(w,l,r)RMQ(w,l,r) denotes the index of…
链接:https://ac.nowcoder.com/acm/contest/889/D来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Amy asks Mr. B  problem D. Please help Mr. B to solve the following problem. Amy wants to crack Merkle–Hellman knapsack…
题意:求Σfi^m%p. zoj上p是1e9+7,牛客是1e9:  对于这两个,分别有不同的做法. 前者利用公式,公式里面有sqrt(5),我们只需要二次剩余求即可.     后者mod=1e9,5才mod下没有二次剩余,所以不能这么做了.可以分解mod,然后利用循环节搞. zoj: #include <bits/stdc++.h> using namespace std; typedef long long LL; ; ; LL fac[N],A[N],B[N]; void Init() {…
链接:https://ac.nowcoder.com/acm/contest/881/A来源:牛客网 题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r)RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1≤l≤r≤mwhere RMQ(w,l,r)RMQ(w,l,r) denotes the inde…
链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Equivalent Prefixes 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if R M Q ( u ,…
题意:https://ac.nowcoder.com/acm/contest/881/I 给你n个平面上的点,每个点有a.b两个权值,现在让你划分成两个区域(要求所有A集合里的点不能在任何B集合里的点的右下方). 求MAX(Sigma ai+Sigma bi). 思路: dp+线段树. https://blog.csdn.net/qq_41194925/article/details/97079075 就是有一个要注意的地方:对于枚举的点我们算的是B集合所以dp[i]=max(1~i)+bi,这…
题意:https://ac.nowcoder.com/acm/contest/882/E 给你01矩阵,有两种操作:1是把一个位置0变1.1变0,2是问你从第一行i开始,到最后一行j有几种走法.你只能不能向上走而且不能往回走. 思路: 01矩阵里每一行可以用一个矩阵表示向下有几种走法,i行到j行的的走法就是各行的矩阵的乘积.用线段树维护即可. 线段树seg[1]的[x][y]就是答案. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #…
题意 给出n个点,每个点有a,b两个属性,让你从左下角到右上角划一条线,线的左边每个点的贡献是\(a_i\),线的右边每个点的贡献是\(b_i\),使得两部分的总和最大. 分析 找一条折线将点分割开,使总和最大. 把y离散化,然后点按x排序,设\(dp[i]\)为经过第\(i\)个点(该点当作B集合中的点)的折线的权值,之前的点中在这个点上面的点dp值要加上\(b[i]\),之前的点中在这个点下面的点的dp值要加上\(a[i]\) \(dp[i]=max(dp[i],dp[k]+b[i]),y[…