csu 1552: Friends 二分图 + Miller_Rabin】的更多相关文章

http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1552 把那n个数写两次,分成相同的两堆,判断相加是质数的,连一条边,然后找最大匹配,ans = 最大匹配 / 2 做的时候一直超时,原来是Miller_Rabin的quick_pow那里需要quick_mul配合,不然溢出. #include <stdio.h> #include <stdlib.h> #include <cstring> #include <…
1552: Friends Time Limit: 3 Sec  Memory Limit: 256 MBSubmit: 723  Solved: 198[Submit][Status][Web Board] Description On an alien planet, every extraterrestrial is born with a number. If the sum of two numbers is a prime number, then two extraterrestr…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1552 Description On an alien planet, every extraterrestrial is born with a number. If the sum of two numbers is a prime number, then two extraterrestrials can be friends. But every extraterrestr…
1552: Friends Time Limit: 3 Sec  Memory Limit: 256 MBSubmit: 163  Solved: 34[Submit][Status][Web Board] Description On an alien planet, every extraterrestrial is born with a number. If the sum of two numbers is a prime number, then two extraterrestri…
Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Java/Others)Total Submission(s): 4728    Accepted Submission(s): 1552 Problem Description You’re giving a party in the garden of your villa by the sea. The p…
BZOJ 洛谷 \(Solution\) 很显然的建二分图后跑最大费用流,但有个问题是一个数是只能用一次的,这样二分图两部分都有这个数. 那么就用两倍的.如果\(i\)可以向\(j'\)连边,\(j\)也向\(i'\)连边,如果上一次走了\(i->j'\),那么这一次一定走\(j->i'\). 每次跑最大费用流,直至有一次费用变成负,然后加上当前正权值能抵消它的流量,最后总流量除以2就可以了. \(Another Solution\) 两个数能匹配首先要能整除,其次它们所有质因子的次数和一定只…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1508 题意:地图中四联通的块是一个国家,A和B每个人可以涂两种颜色,且B不能涂超过5次,相邻的国家不能涂一样的颜色,并且最后每种颜色都要用上,问共有多少种涂色方案. 思路:先DFS处理出图中的国家,然后先用一个邻接矩阵存下相邻的国家(直接用邻接表会有重边),然后再用邻接表存图.数方案个数的时候,假设共有a,b,c,d这四种颜色,A可以涂a,b,B可以涂c,d.因为颜色之间没有差异,所以A先涂a颜…
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 688C uDebug Description   Input   Output   Sample Input   Sample Output   Hint…
Destroying The Graph Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8198   Accepted: 2635   Special Judge Description Alice and Bob play the following game. First, Alice draws some directed graph with N vertices and M arcs. After that B…
支持加边和删边的二分图判定,分治并查集水之(表示我的LCT还很不熟--仅仅停留在极其简单的模板水平). 由于是带权并查集,并且不能路径压缩,所以对权值(到父亲距离的奇偶性)的维护要注意一下. 有一个小优化:如果当前图已经不是二分图就不再继续dfs线段树,直接把区间内的每个答案设为No后回溯即可. 这次写了个按size合并,不过随机合并比按size合并还快一点是什么鬼-- 按size合并的代码: /**************************************************…