相应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.…
题意:每片雪花有六瓣,给出n片雪花,六瓣花瓣的长度按顺时针或逆时针给出,判断其中有没有相同的雪花(六瓣花瓣的长度相同) 思路:如果直接遍历会超时,我试过.这里要用哈希表,哈希表的关键码key用六瓣花瓣的长度的和取余一个数得到,表中为雪花的存储位置address(即在snowflakes数组中的位置) 代码: #include<iostream> #include<vector> using namespace std; const int maxn=100000+100;//雪花最…
题意:给定n(0 < n ≤ 100000)个雪花,每个雪花有6个花瓣(花瓣具有一定的长度),问是否存在两个相同的雪花.若两个雪花以某个花瓣为起点顺时针或逆时针各花瓣长度依次相同,则认为两花瓣相同. 分析: 1.按雪花各花瓣长度之和对MOD取余哈希.对各雪花,算出哈希值,在哈希表中查询是否有与之相同的花瓣. 2.每个花瓣以某个花瓣为起点顺时针或逆时针共有12种表示方法. 3.注意哈希表中只需保存雪花输入时给定的那组长度值即可. 在哈希表中查询时,再算出该组长度值所对应的12种表示,并一一比较,若…
题目链接:http://poj.org/problem?id=3349 题意:雪花有6个瓣,有n个雪花,输入每个雪花的瓣长,判断是否有一模一样的雪花(通过旋转或翻转最终一样,即瓣长对应相等).如果前面的雪花判断出有重复,则不需对后续的进行操作. 题解:直接将花瓣存在二维数组里面,然后每次新输入一个,再对之前的进行遍历判重.但是这种做法很低效,遍历花了很多时间.所以用哈希表,可直接访问是否存在重复,如果不重复,则用一维数组将雪花存起来(数组包含在结构体里),并将其"挂"在相应的哈希值(k…
题意:判断有没有两朵相同的雪花.每朵雪花有六瓣,比较花瓣长度的方法看是否是一样的,如果对应的arms有相同的长度说明是一样的.给出n朵,只要有两朵是一样的就输出有Twin snowflakes found.,如果任何两个都是不一样的输出No two snowflakes are alike.n=100,000. 思路:最简单的就是枚举每两片雪花,判断他们是否相同.时间复杂度为O(n*n),显然效果不理想.有没有更好的算法呢?hash:每读进一片雪花,将雪花hash,判断hash表里是否有相同的h…