相应POJ题目:点击打开链接 Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 33595   Accepted: 8811 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is…
Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 39324   Accepted: 10298 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true.…
Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 30529   Accepted: 8033 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Y…
Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 30512   Accepted: 8024 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Y…
Snowflake Snow Snowflakes Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 27598 Accepted: 7312 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your…
Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 48646   Accepted: 12703 Description You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true.…
http://poj.org/problem?id=3349 题意 :分别给你n片雪花的六个角的长度,让你比较一下这n个雪花有没有相同的. 思路:一开始以为把每一个雪花的六个角的长度sort一下,然后再跟别的比,可实际上不是这样的,两个雪花相同的时候,角的顺序是固定的,可以是逆时针的也可以是顺时针的,因为雪花可以转动嘛,例如213456 和216543就是不一样的,这个题本身分类就是哈希,但是看到讨论里有人用暴力过的,,,我很是佩服,我压根就没往那个方面想,也许分类是哈希,我就认定哈希了吧,思维…
题意:每片雪花有六瓣,给出n片雪花,六瓣花瓣的长度按顺时针或逆时针给出,判断其中有没有相同的雪花(六瓣花瓣的长度相同) 思路:如果直接遍历会超时,我试过.这里要用哈希表,哈希表的关键码key用六瓣花瓣的长度的和取余一个数得到,表中为雪花的存储位置address(即在snowflakes数组中的位置) 代码: #include<iostream> #include<vector> using namespace std; const int maxn=100000+100;//雪花最…
题意:判断有没有两朵相同的雪花.每朵雪花有六瓣,比较花瓣长度的方法看是否是一样的,如果对应的arms有相同的长度说明是一样的.给出n朵,只要有两朵是一样的就输出有Twin snowflakes found.,如果任何两个都是不一样的输出No two snowflakes are alike.n=100,000. 思路:最简单的就是枚举每两片雪花,判断他们是否相同.时间复杂度为O(n*n),显然效果不理想.有没有更好的算法呢?hash:每读进一片雪花,将雪花hash,判断hash表里是否有相同的h…
题意:给定n(0 < n ≤ 100000)个雪花,每个雪花有6个花瓣(花瓣具有一定的长度),问是否存在两个相同的雪花.若两个雪花以某个花瓣为起点顺时针或逆时针各花瓣长度依次相同,则认为两花瓣相同. 分析: 1.按雪花各花瓣长度之和对MOD取余哈希.对各雪花,算出哈希值,在哈希表中查询是否有与之相同的花瓣. 2.每个花瓣以某个花瓣为起点顺时针或逆时针共有12种表示方法. 3.注意哈希表中只需保存雪花输入时给定的那组长度值即可. 在哈希表中查询时,再算出该组长度值所对应的12种表示,并一一比较,若…