poj 3349 Snowflake Snow Snowflakes
来源:互联网 发布:剑三花姐捏脸数据 编辑:程序博客网 时间:2024/06/05 18:49
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 program will read information about a collection of snowflakes, and search for a pair that may be identical. Each snowflake has six arms. For each snowflake, your program will be provided with a measurement of the length of each of the six arms. Any pair of snowflakes which have the same lengths of corresponding arms should be flagged by your program as possibly identical.
Input
The first line of input will contain a single integer n, 0 < n ≤ 100000, the number of snowflakes to follow. This will be followed by n lines, each describing a snowflake. Each snowflake will be described by a line containing six integers (each integer is at least 0 and less than 10000000), the lengths of the arms of the snow ake. The lengths of the arms will be given in order around the snowflake (either clockwise or counterclockwise), but they may begin with any of the six arms. For example, the same snowflake could be described as 1 2 3 4 5 6 or 4 3 2 1 6 5.
Output
If all of the snowflakes are distinct, your program should print the message:
No two snowflakes are alike.
If there is a pair of possibly identical snow akes, your program should print the message:
Twin snowflakes found.
Sample Input
21 2 3 4 5 64 3 2 1 6 5
Sample Output
Twin snowflakes found.
大意:读取有关雪花集合的信息,并搜索可能相同的对。每个雪花有六条胳膊。对于每个雪花,你的程序将提供
一个测量六个臂的每一个的长度。任何具有相同长度的相应臂的雪花应该被你的程序标记为可能相同。
解法:每个数字平方和hash,找到相同直接输出
const maxn=1000007;var a:array[0..maxn] of qword; n,x,i,j,k:longint; p:qword;function locate(t:qword):longint;var tmp:longint;begin tmp:=t; while (a[tmp]<>0) and (a[tmp]<>k) do tmp:=(tmp+1) mod maxn; locate:=tmp;end;begin readln(n); for j:=1 to n do begin p:=0; k:=0; for i:=1 to 6 do begin read(x); k:=k+x; p:=(p+x*x) mod maxn; end; if a[locate(p)]=k then begin writeln('Twin snowflakes found.');halt;end; a[locate(p)]:=k; end; writeln('No two snowflakes are alike.');end.
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- poj 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- poj-3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- poj 3349 Snowflake Snow Snowflakes
- POJ 3349 Snowflake Snow Snowflakes
- poj 3349 Snowflake Snow Snowflakes
- poj 3349 Snowflake Snow Snowflakes
- POJ-3349 Snowflake Snow Snowflakes
- poj 3349 Snowflake Snow Snowflakes
- 循环遍历标签的值
- [排序算法,选择排序]--简单选择排序
- 编程算法练习
- Windows镜像制作
- WC2017
- poj 3349 Snowflake Snow Snowflakes
- std::function
- Markdown编辑器使用
- 每天一个linux命令(1):wget命令
- 编程算法练习(1.12)
- 从本地到云服务器复制文件(转)
- 阿里巴巴2016双11背后的技术(不一样的技术创新)
- iOS中webView的三种用法
- testng翻译之四--Running TestNG