摘要:
http://poj.org/problem?id=3349题意:给出n组数据,每组数据有六个数,这n组数据中若有两组数据不管是从某个数顺时针读还是逆时针读都相同,输出“Twin snowflakes found.”,否则,输出"No two snowflakes are alike."思路:将每组数据求和对大素数取余,将sum相同的放在同一个邻接表中,然后从邻接表中查找符合条件的数据。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int p=99983; 8 co 阅读全文
posted @ 2013-08-23 20:31
N_ll
阅读(295)
评论(0)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1468简单的素数筛选会超时,因为是多组,所以先打表会更快,这样就不用每次都筛选了。 1 #include 2 #include 3 #include 4 const int N=1000002; 5 long long a[N]; 6 void printf_prime( ) 7 { 8 a[1] = 0; 9 a[2] = 1;10 for (int i = 3; i < N; i ++)11 {12 ... 阅读全文
posted @ 2013-08-23 17:22
N_ll
阅读(166)
评论(0)
推荐(0)
摘要:
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2497题意:给定一些点和边的关系,判断S点是否在所构成无向图的所有环里。思路:用并查集将所有(除去S及与 S有关的点)有关系的点放在一个集合里,若此时图中还存在环,那么一定不包含S。 1 #include 2 #include 3 const int maxn = 10002; 4 5 int f[maxn],n; 6 int find(int x) 7 { 8 if (x!=f[x]) 9 f[x] = find(f[x... 阅读全文
posted @ 2013-08-23 15:36
N_ll
阅读(226)
评论(0)
推荐(0)

浙公网安备 33010602011771号