摘要: 找到规律模拟就可以了,用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) 编辑
摘要: 有n个家庭,m个房间,一个房间只能两个家庭住。求最大匹配。 比较标准的二分图问题。先初始化把可能的家庭建边,然后跑一边匈牙利算法。 最后的答案是最大匹配数/2,因为建图时有重复。 #include <cstdio> #include <algorithm> #include <cstring> #i 阅读全文
posted @ 2016-02-17 23:19 Helica 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 有两段字符串,第一段的尾和第二段的头可能重合。问有多少种组合的可能。 需要理解一下next数组的意义。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 10 阅读全文
posted @ 2016-02-17 23:15 Helica 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 很水的模拟题,拿数组搞就好了。 注意边界的地方不要算重。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int N,T,M; int save[10000]; char str[1000] 阅读全文
posted @ 2016-02-17 23:04 Helica 阅读(184) 评论(0) 推荐(0) 编辑