POJ_3349 Snowflake Snow Snowflakes

本文介绍了一个程序,用于检测是否真的没有两片雪花相同。通过读取雪花的臂长信息,程序会寻找可能相同的雪花对。每个雪花的臂长信息以特定顺序给出,程序通过比较这些信息来确定雪花是否相似。
Snowflake Snow Snowflakes
Time Limit: 4000MSMemory Limit: 65536K
Total Submissions: 18478Accepted: 4770

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

2
1 2 3 4 5 6
4 3 2 1 6 5

Sample Output

Twin snowflakes found.

Source

ContractedBlock.gifExpandedBlockStart.gifView Code
#include <stdio.h>
#include
<string.h>
#define len 140000
#define mod 139997
#define N 100010

int flack[N][6];

struct node
{
int key;
struct node * next;
}snow[N];

struct node *hash[len];

int get_int(void)
{
char ch;
int num = 0;
while((ch = getchar())== ' ' || ch == '\n')
;
while(ch >= '0' && ch <= '9')
{
num
= num * 10 + ch - '0';
ch
= getchar();
}
return num;
}

int same(int x, int y)
{
int i, j, k;
int tmp[12];
for(i = 0; i < 6; i++)
{
tmp[i]
= flack[x][i];
tmp[i
+6] = flack[x][i];
}
j
= 0;
i
= 0;
while(i < 12)
{
while(i < 12 && tmp[i] != flack[y][j])
i
++;
k
= i;
while(i < 12 && tmp[i] == flack[y][j])
{
j
++;
i
++;
if(j == 6)
return 1;
}
i
= k+1;
j
= 0;
}
i
= 11;
while(i >= 0)
{
while(i >= 0 && tmp[i] != flack[y][j])
i
--;
k
= i;
while(i >= 0 && tmp[i] == flack[y][j])
{
i
--;
j
++;
if(j == 6)
return 1;
}
j
= 0;
i
= k-1;
}
return 0;
}

int check(struct node *l, int i)
{
while(l != NULL)
{
if(same(l->key,i))
return 1;
l
= l->next;
}
return 0;
}

int main()
{
int n, i, j, flag = 0, sum;
scanf(
"%d",&n);
for(i = 1; i <= n; i++)
{
sum
= 0;
for(j = 0; j < 6; j++)
{
flack[i][j]
= get_int();
sum
+= flack[i][j];
}
sum
%= mod;
snow[i].key
= i;
if(hash[sum] == NULL)
{
hash[sum]
= &snow[i];
}
else if(check(hash[sum],i))
{
flag
= 1;
break;
}
else
{
snow[i].next
= hash[sum];
hash[sum]
= &snow[i];
}
}
if(flag)
printf(
"Twin snowflakes found.\n");
else
printf(
"No two snowflakes are alike.\n");
return 0;
}
标题SpringBoot智能在线预约挂号系统研究AI更换标题第1章引言介绍智能在线预约挂号系统的研究背景、意义、国内外研究现状及论文创新点。1.1研究背景与意义阐述智能在线预约挂号系统对提升医疗服务效率的重要性。1.2国内外研究现状分析国内外智能在线预约挂号系统的研究与应用情况。1.3研究方法及创新点概述本文采用的技术路线、研究方法及主要创新点。第2章相关理论总结智能在线预约挂号系统相关理论,包括系统架构、开发技术等。2.1系统架构设计理论介绍系统架构设计的基本原则和常用方法。2.2SpringBoot开发框架理论阐述SpringBoot框架的特点、优势及其在系统开发中的应用。2.3数据库设计与管理理论介绍数据库设计原则、数据模型及数据库管理系统。2.4网络安全与数据保护理论讨论网络安全威胁、数据保护技术及其在系统中的应用。第3章SpringBoot智能在线预约挂号系统设计详细介绍系统的设计方案,包括功能模块划分、数据库设计等。3.1系统功能模块设计划分系统功能模块,如用户管理、挂号管理、医生排班等。3.2数据库设计与实现设计数据库表结构,确定字段类型、主键及外键关系。3.3用户界面设计设计用户友好的界面,提升用户体验。3.4系统安全设计阐述系统安全策略,包括用户认证、数据加密等。第4章系统实现与测试介绍系统的实现过程,包括编码、测试及优化等。4.1系统编码实现采用SpringBoot框架进行系统编码实现。4.2系统测试方法介绍系统测试的方法、步骤及测试用例设计。4.3系统性能测试与分析对系统进行性能测试,分析测试结果并提出优化建议。4.4系统优化与改进根据测试结果对系统进行优化和改进,提升系统性能。第5章研究结果呈现系统实现后的效果,包括功能实现、性能提升等。5.1系统功能实现效果展示系统各功能模块的实现效果,如挂号成功界面等。5.2系统性能提升效果对比优化前后的系统性能
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值