hdu5365 簡單幾何問題
http://acm.hdu.edu.cn/showproblem.php?pid=5365
Problem Description
AFA is a girl who like runing.Today,he download an app about runing .The app can record the trace of her runing.AFA will start runing in the park.There are many chairs in the park,and AFA will start his runing in a chair and end in this chair.Between two chairs,she
running in a line.she want the the trace can be a regular triangle or a square or a regular pentagon or a regular hexagon.
Please tell her how many ways can her find.
Two ways are same if the set of chair that they contains are same.
Please tell her how many ways can her find.
Two ways are same if the set of chair that they contains are same.
Input
There are multiply case.
In each case,there is a integer n(1 < = n < = 20)in a line.
In next n lines,there are two integers xi,yi(0 < = xi,yi < 9) in each line.
In each case,there is a integer n(1 < = n < = 20)in a line.
In next n lines,there are two integers xi,yi(0 < = xi,yi < 9) in each line.
Output
Output the number of ways.
Sample Input
4
0 0
0 1
1 0
1 1
Sample Output
1
/**
hdu5365 簡單幾何問題
題目大意:小花是一個熱愛健身的姑娘,這天她下載了一個跑步軟體,這個軟體可以記錄下小花跑步的軌跡。小花決定去公園跑步。
公園裡有許許多多的座椅,小花希望在一些座椅休息一下,並且她在兩條座椅之間只跑直線。小花是一個完美主義者,
她希望自己最後的軌跡是一個正三邊形或者正四邊形或者正五邊形或者正六邊形。小花會從某條座椅開始開啟跑步軟體,
並在回到這個座椅後關閉。請問小花有多少種跑法。注:若兩種跑法經過的座椅集合相同則認為是一種跑法。且經過一
條座椅時沒有必要一定停下來
解題思路:地球人都知道整點是不能構成正五邊形和正三邊形和正六邊形的,所以只需暴力列舉四個點判斷是否是正四邊形即可。
假如你不是地球人,那麼即使暴力列舉正三邊形和稍微不那麼暴力地找正五邊形和正六邊形也是可以通過的(反正找不到)。
*/
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct note
{
int x,y;
}a[105];
int n;
int len(int x,int y,int u,int v)
{
return (x-u)*(x-u)+(y-v)*(y-v);
}
int judge(int i,int j,int k,int l)///片面內給定四個點的座標判斷是否構成正方形(求出各邊長,排序,判斷邊的關係)
{
vector <int> vec;
vec.push_back(len(a[i].x,a[i].y,a[j].x,a[j].y));
vec.push_back(len(a[i].x,a[i].y,a[k].x,a[k].y));
vec.push_back(len(a[i].x,a[i].y,a[l].x,a[l].y));
vec.push_back(len(a[j].x,a[j].y,a[k].x,a[k].y));
vec.push_back(len(a[k].x,a[k].y,a[l].x,a[l].y));
vec.push_back(len(a[l].x,a[l].y,a[j].x,a[j].y));
sort(vec.begin(),vec.end());
if(vec[0]==vec[1]&&vec[1]==vec[2]&&vec[2]==vec[3]&&vec[1]*2==vec[4]&&vec[4]==vec[5])
return true;
return false;
}
int main()
{
while(~scanf("%d",&n))
{
for(int i=0;i<n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
}
int sum=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
for(int k=j+1;k<n;k++)
{
for(int l=k+1;l<n;l++)
{
if(judge(i,j,k,l))sum++;
}
}
}
}
printf("%d\n",sum);
}
return 0;
}
相關文章
- The Center of Gravity(一道很很簡單的幾何題)
- 求助:Spring web framework(jpetstore)中幾個簡單的問題SpringWebFramework
- 計算幾何(一):凸包問題(Convex Hull)
- HDU 1077Catching Fish(簡單計算幾何)
- 簡單說幾個MySQL高頻面試題MySql面試題
- 幾個把平面幾何問題的輔助線做到空間去的數學趣題
- codeforces #340B(簡單計算幾何 自己想複雜了)
- 幾道經典的幾何作圖趣題
- 數學趣題:平面幾何(一)
- 數學趣題:平面幾何(二)
- 俄羅斯總理的幾何題
- tcp 實現簡單http 問題TCPHTTP
- 簡單問題,封裝和框架!封裝框架
- jsf取值的簡單問題JS
- 簡單幾步解決win10平板qq遊戲安裝失敗問題Win10遊戲
- JSXGraph幾何繪圖證明解答【五點共圓】問題JS繪圖
- 簡單的素數問題(C++)C++
- 用簡單的方法解決問題
- 簡單問題複雜著解決
- 簡單幾步解決win10應用商店登陸遇到錯誤問題Win10
- 簡單幾步解決w10系統外接螢幕不能全屏的問題
- 簡單幾步解決win10 ghost您的電腦遇到問題的方法Win10
- 簡單幾步教你解決win10更新amd顯示卡驅動藍屏問題Win10
- wsj:雅虎的訪問量價值幾何?
- 簡單幾步解決win10瀏覽器無法上網qq能上問題Win10瀏覽器
- 一個applet的簡單問題APP
- 關於兩個簡單問題的分析
- 面試現場簡單幾道java演算法題, 你能寫出幾道?面試Java演算法
- aix的幾個簡單命令AI
- 簡單幾步教你解決win10更新amd顯示卡驅動藍色畫面問題Win10
- 計算幾何
- iOS FTPManager的簡單使用及常見問題iOSFTP
- Centos 系統簡單排查流量異常問題CentOS
- php簡單演算法 - 肇事車輛問題PHP演算法
- HBase-Region太多的問題簡單總結
- NodeJS require路徑問題簡單介紹NodeJSUI
- 海量資料查詢問題--簡單的理解
- 問一個關於oracle8的簡單的問題!Oracle