摘要: 二分。 #include #include #include using namespace std; const int maxn = 50000 + 10; int n,k,l,r,mid,ans,d; int a[maxn]; bool check(int dist) { dist=2*dist; int d=0,sum=1; for(int i=2;id... 阅读全文
posted @ 2016-05-20 21:32 invoid 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 前缀和. 设f[i]为前缀和%7=i的第一个点。那么答案就是max(i-f[s[i]%7])了。 #include #include #include using namespace std; const int maxn = 50000 + 10; int a[maxn],s[maxn]; int f[10],n,ans; int main() { for(int i... 阅读全文
posted @ 2016-05-20 21:31 invoid 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 筛法。 枚举每个数,它会对它的倍数的答案有贡献。 数大了以后,倍数相应少了很多。比枚举每个数的约数要好的多。 自己yy了一种分步做法。小于sqrt(m)被当作约数枚举,大于sqrt(m)的枚举倍数。 #include #include #include using namespace std; const int maxn = 1000000 + 10; int a[maxn],... 阅读全文
posted @ 2016-05-20 19:36 invoid 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 最小生成树+dfs。 首先可知某一特定权值的边的数量在不同的最小生成树是确定的。(可以用反证法yy一下) 这样先用kruskal算法求最小生成树,一边统计某种边用的数量。 然后dfs一下(就是枚举每条边有没有,因为相同权值的边最多只有10条,所以是O(2^n)的枚举可以胜任)。 同时要注意图是否联通,不联通输出0. #include #include #include using ... 阅读全文
posted @ 2016-05-20 16:49 invoid 阅读(297) 评论(0) 推荐(0) 编辑
摘要: tarjan缩点。网上的代码都没有缩点是把vis变成另外一个值,我也不知道是为什么。 #include #include #include using namespace std; const int maxn = 200000 + 10; const int maxm = 1000000 + 10; int g[maxn],v[maxm],next[maxm],eid; int n,m... 阅读全文
posted @ 2016-05-20 09:55 invoid 阅读(155) 评论(0) 推荐(0) 编辑