上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要: 1 #include <cstring> 2 #include <algorithm> 3 #include <iostream> 4 #include <queue> 5 6 using namespace std; 7 8 typedef long long LL; 9 const int ma 阅读全文
posted @ 2016-02-21 17:08 Helica 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 用dp求出最大的表达,再用dp求出。//然而并没有想出来 1 #include <cstdio> 2 #include <string> 3 #include <algorithm> 4 #include <iostream> 5 6 using namespace std; 7 8 const i 阅读全文
posted @ 2016-02-21 17:05 Helica 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 裸网络流题。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #include <queue> 5 using namespace std; 6 7 const int maxn = 1200; 8 const in 阅读全文
posted @ 2016-02-21 16:59 Helica 阅读(446) 评论(0) 推荐(0) 编辑
摘要: 经过研究可以发现,每一位的贡献是C(n-2,k-1)+C(n-3,k-1)...C(k-1,k-1) 同时还要注意加号全部在左边的情况。 这里还用了O(n)预处理O(1)组合数的模板。//妙啊。。妙。。。 1 #include <cstdio> 2 #include <cstring> 3 #inc 阅读全文
posted @ 2016-02-21 16:55 Helica 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 树上每个元素有一个p,元素之间有距离d,计算一个元素u,使得sigma(d(i,u)*pi)最小。 两次dfs,第一次计算本节点以下的sigma(),第二次利用sump求解出ans。 1 #include <cstdio> 2 #include <algorithm> 3 #include <cst 阅读全文
posted @ 2016-02-21 16:47 Helica 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 有一个串,有黑色和白色两种元素。一次操作可以把最上面的白色元素变成黑色,同时把这个元素上面的所有元素变成白色。 给你一个30以内的串,计算变成全黑时,元素变化的总和。 我用的方法比较笨,打表处理了1-30个全白串变黑的ans,然后模拟,借助打表的结果计算出答案。 其实,每出现一个白色元素 cnt+= 阅读全文
posted @ 2016-02-21 16:42 Helica 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 从1-a和1-b种选两个数xy,计算出令gcd(x,y)=k的xy的对数。 对于每一个i∈[1,b]使用solve(i,n)函数解决有几个j∈[1,n]使gcd(x,y)=k。然后累加solve(i,n)-solve(i,i)即可,注意边界情况。 solve函数则使用容斥原理。 #include < 阅读全文
posted @ 2016-02-18 13:36 Helica 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 给出N个MAXN以内的不同的数,求出素因子最大的数。 使用朴素的方法分解素因子即可。时间复杂度为N*log(MAXN) 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 5 using namespace std; 6 阅读全文
posted @ 2016-02-18 13:21 Helica 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 找到规律模拟就可以了,用DFS模拟很简洁,用循环模拟比较直观(大概吧) 注意输入输出用%llu,1ULL<<64=0!被这几个小问题卡了好久 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; 阅读全文
posted @ 2016-02-17 23:25 Helica 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 依次考虑一个数的倍数,两个数的倍数(lcm),三个数的倍数(lcm)。。。 会发现有这么一个规律,奇数个数时要加上情况数,偶数个数时要减去情况数。 一种只有10个数,用二进制枚举所有情况即可。 #include <cstdio> #include <algorithm> #include <cstr 阅读全文
posted @ 2016-02-17 23:23 Helica 阅读(255) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页