HDU 6055
2024-10-06 10:16:15
题意略。
思路:要你找出所有正多边形,其实是唬人的,整点的正多边形只有正方形,具体证明可以参考 2017国家队论文集-《正多边形》-杨景钦
详见代码:
#include<bits/stdc++.h>
#define maxn 505
//#define LOCAL
using namespace std; struct Point{
int x,y;
Point(int a = ,int b = ){
x = a,y = b;
}
Point operator+ (const Point& p){
return Point(x + p.x,y + p.y);
}
Point operator- (const Point& p){
return Point(x - p.x,y - p.y);
}
bool operator== (const Point& p) const{
return x == p.x && y == p.y;
}
bool operator< (const Point& p) const{
if(x != p.x) return x < p.x;
return y < p.y;
}
}; struct line{
Point s,t;
line(){}
line(Point a,Point b){
s = a,t = b;
}
bool operator< (const line& l) const{
if(!(s == l.s)) return s < l.s;
return t < l.t;
}
}; set<line> st;
Point store[maxn * maxn]; int main(){
#ifdef LOCAL
freopen("kkk.txt","r",stdin);
freopen("kkkout.txt","w",stdout);
#endif
int n;
while(scanf("%d",&n) == ){
st.clear();
for(int i = ;i < n;++i)
scanf("%d%d",&store[i].x,&store[i].y);
sort(store,store + n);
for(int i = ;i < n;++i){
for(int j = i + ;j < n;++j){
st.insert(line(store[i],store[j]));
}
}
int ans = ;
for(int i = ;i < n;++i){
for(int j = i + ;j < n;++j){
Point d = store[j] - store[i];
Point temp(d.y,-d.x);
Point s = store[i] + temp;
Point t = s + d;
if(st.count(line(s,t))) ++ans;
}
}
printf("%d\n",ans / );
}
return ;
}
最新文章
- C++产生随机数
- 这些年正Android - 母亲
- Senparc.Weixin.MP SDK 微信公众平台开发教程(五):使用Senparc.Weixin.MP SDK
- UIControlEventTouch
- 课堂Scrum站立会议演示
- 常用jQuery代码01
- Telerik RadGrid Demo
- 15 个响应式的 jQuery 图像滑块插件
- 局域网内使用linux的ntp服务
- 洛谷2344 奶牛抗议(DP+BIT+离散化)
- android Log.isLoggable步骤的使用
- Jmeter -- 初体验
- [BZOJ]1095 Hide捉迷藏(ZJOI2007)
- dict-test
- glove
- raft--分布式一致性协议
- 如何将 iOS 工程打包速度提升十倍以上
- RNA-seq连特异性
- 【异常记录(六)】vs文件乱码:文件加载,使用Unicode(UTF-8)编码加载文件xxx时,有些字节已用Unicode替换字符替换。保存该文件将不会保留原始文件内容。
- Django分页的实现