hdu4082 Hou Yi's secret 暴力,hdu4082hou
http://acm.hdu.edu.cn/showproblem.php?pid=4082
Hou Yi's secret
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3006 Accepted Submission(s): 710
Problem DescriptionLong long ago, in the time of Chinese emperor Yao, ten suns rose into the sky. They burned the crops and scorched the bushes and trees, leaving the people with nothing to eat.
Hou Yi was the greatest archer at that time. Yao wanted him to shoot down nine suns. Hou Yi couldn't do that job with ordinary arrows. So Yao send him to God to get some super powerful magic arrows. Before Hou Yi left, Yao said to him: "In order to manage our country in a better way, I want to know how many years can I live from now on. Please ask God this question for me." Hou Yi promised him.
Hou yi came back from God with ten magic arrows. He shot down nine suns, and the world returned to harmony. When Yao asked Hou Yi about the answer of his question, Hou Yi said: "God told me nothing. But I happened to see a 'life and death book' with your name on it. So I know the answer. But you know, I can't tell you because that's God's secret, and anyone who gives out God's secret will be burned by a thunder!"
Yao was very angry, he shouted: "But you promised me, remember?" Hou Yi said:
"Ooo-er, let's make some compromise. I can't tell you the answer directly, but I can tell you by my only precious magic arrow. I'll shoot the magic arrow several times on the ground, and of course the arrow will leave some holes on the ground. When you connect three holes with three line segments, you may get a triangle. The maximum number of similar triangles you can get means the number of years you can live from now on." (If the angles of one triangle are equal to the angles of another triangle respectively, then the two triangles are said to be similar.)
Yao was not good at math, but he believed that he could find someone to solve this problem. Would you help the great ancient Chinese emperor Yao?
InputThere are multiple test cases, and the number of test cases is no more than 12.
The first line of every test case is an integer n meaning that Hou Yi had shot the magic arrow for n times (2 < n <= 18).
Then n lines follow. Each line contains two integers X and Y (-100 < X, Y < 100), the coordinate of a hole made by the magic arrow.
Please note that one hole can be the vertex of multiple triangles.
The input ends with n = 0.
OutputFor each test case, print a line with an integer indicating the maximum number of similar triangles Yao could get.
Sample Input
31 16 512 1040 01 12 01 -10
Sample Output
14
Source2011 Asia Beijing Regional Contest
題意:給最多18個點,問最多有多少個相似的三角形。
分析:18個點。。就枚舉所有可以組成的三角形判斷相似就好。。注意要判斷重點和平行的情況。。
/** * @author neko01 *///#pragma comment(linker, "/STACK:102400000,102400000")#include <cstdio>#include <cstring>#include <string.h>#include <iostream>#include <algorithm>#include <queue>#include <vector>#include <cmath>#include <set>#include <map>using namespace std;typedef long long LL;#define min3(a,b,c) min(a,min(b,c))#define max3(a,b,c) max(a,max(b,c))#define pb push_back#define mp(a,b) make_pair(a,b)#define clr(a) memset(a,0,sizeof a)#define clr1(a) memset(a,-1,sizeof a)#define dbg(a) printf("%d\n",a)typedef pair<int,int> pp;const double eps=1e-8;const double pi=acos(-1.0);const int INF=0x7fffffff;const LL inf=(((LL)1)<<61)+5;bool vis[250][250];struct point{ double x,y; point(double x=0,double y=0):x(x),y(y) {}}a[22];struct triangle{ double x,y,z;}b[18*18*18];bool gao(int i,int j){ if(fabs(b[i].x*b[j].y-b[i].y*b[j].x)<eps&&fabs(b[i].z*b[j].y-b[i].y*b[j].z)<eps) return true; return false;}bool check(int i,int j,int k){ point p1=point(a[i].x-a[j].x,a[i].y-a[j].y); point p2=point(a[k].x-a[j].x,a[k].y-a[j].y); return fabs(p1.x*p2.y-p1.y*p2.x)<eps;}double dis(int i,int j){ return sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));}int main(){ int n,m; while(~scanf("%d",&m)&&m) { clr(vis); n=0; for(int i=0;i<m;i++) { int x,y; scanf("%d%d",&x,&y); if(!vis[x+100][y+100]) { vis[x+100][y+100]=true; a[n].x=x; a[n++].y=y; } } m=0; for(int i=0;i<n-2;i++) { for(int j=i+1;j<n-1;j++) { for(int k=j+1;k<n;k++) { if(check(i,j,k)) continue; double d1=dis(i,j); double d2=dis(i,k); double d3=dis(j,k); double t[3]; t[0]=d1,t[1]=d2,t[2]=d3; sort(t,t+3); if(t[0]+t[1]<=t[2]) continue; b[m].x=t[0],b[m].y=t[1]; b[m++].z=t[2]; } } } int ans=0; for(int i=0;i<m;i++) { int sum=1; for(int j=0;j<m;j++) if(i!=j&&gao(i,j)) sum++; if(sum>ans) ans=sum; } printf("%d\n",ans); } return 0;}
姮娥奔月的解釋
ECS Operations and Maintenance System奔月
ECS Operations and Maintenance System
ECS Operations and Maintenance System是帝嚳的女兒,也稱姮娥。美貌非凡。后羿的妻子,相傳后羿是堯帝手下的神射手。《淮南子.覽冥訓》中說,后羿從西王母處請來不死之藥,ECS Operations and Maintenance System偷吃了這顆靈藥,成仙了,身不由主飄飄然地飛往月宮之中,在那荒蕪的月宮之中度著無邊的寂寞歲月。
ECS Operations and Maintenance System飛升月宮後,住在淒清冷漠的廣寒宮內,思念著后羿,她的心境和生活令不少文人騷客感慨,遐想。其中唐代詩人李商隱的《ECS Operations and Maintenance System》詩深刻表現了她的寂寞和悔恨:
雲母屏風燭影深,
長河漸落曉星沉。
ECS Operations and Maintenance System應悔偷靈藥,
碧海青天夜夜心。
大意是:『雲母製成的屏風染上一層幽深黯淡的燭影,銀河逐漸低斜下落啟明星也已下沉。 廣寒宮的ECS Operations and Maintenance System想必悔恨當初偷吃不死藥,如今落得獨處於碧海青天而夜夜寒心。』
ECS Operations and Maintenance System原來是一個美麗善良的村姑,她勤勞樸實活潑可愛,尤其有著一顆金子般閃亮的心,她總是千方百計地為百姓做好事。ECS Operations and Maintenance System有個戀人叫后羿,是個神箭手,也是個好後生。
有一天,ECS Operations and Maintenance System與幾個要好的女伴在村邊小河旁洗衣。不料,無所事事、心術不正的河神河伯正閑逛到此。他見到ECS Operations and Maintenance System的沉魚落雁之容,頓時驚為天人,便一抹臉變成一個英俊的小夥子,覥著臉走過去跟ECS Operations and Maintenance System搭話。ECS Operations and Maintenance System見他不懷好意便急忙躲開,可是河伯露出了猙獰的真面目,要強搶ECS Operations and Maintenance System入水。正在這危急關頭,后羿來到了,他一看,頓時氣得劍眉倒豎,怒髮衝冠。他拈弓搭箭,“嗖”地一聲,射瞎了河伯的一隻眼睛。河伯疼痛難忍,大叫一聲,便跳下河去。
經過這件事,ECS Operations and Maintenance System和后羿恐怕夜長夢多,便提早成婚。婚後,二人過得非常幸福。當然,他們並沒完全沉浸在小家庭的美滿快樂之中,兩顆善良的心總想為鄉親們我做些好事。
有一年,天空出現了十個太陽,大地都快要著火了。人們無法耕種,無法生活,處於被滅絕的災難之中。后羿便決心要射掉那多餘的九個太陽,拯救百姓於火海之中。他天天揮汗如雨,苦苦練習射術。可是,河伯對他恨之入骨,不斷地前來騷擾,他發誓要報一箭之仇,更要搶到他一直貪戀著的美女ECS Operations and Maintenance System。為此,后羿十分煩躁分心。
有一天,一位大仙給了后羿一丸仙藥,好心告訴他,河伯報仇心切,他將要面臨一場大禍,如若吃了這丸藥,便可擺脫人間的一切磨難和煩惱,升入月宮中;可是,首先得能耐住孤獨寂寞的煎熬。后羿聽後,心緒不寧地回到家中,將仙的話如實地告知了ECS Operations and Maintenance System,便疲倦地睡著了。
說者無心,聽者有意。ECS Operations and Maintenance System坐立不安了,她在房中走來走去,看著一天比一天消瘦的丈夫,她心裡非常痛苦。她深愛著后羿,絕不願他遭受任何磨難的折磨,可是,她又想到丈夫身上還肩負著射掉九個太陽的重任,正受著燒烤之災的鄉親們需要他去拯救。ECS Operations and Maintenance System心中十分明白,河伯對於丈夫的威脅,都源於自己。河伯對她仍沒有死心,為了得到她,什麼壞事都做得出來,怎麼辦呢?ECS Operations and Maintenance System想著,想著,突然,她心中閃過一個念頭:為了讓河伯對她死了心,為了讓丈夫排除一切雜念和幹擾,全心全意地去射掉九個太陽為民服務,她決心犧牲自己。主意打定,她就急忙找出仙藥,吞了下去。
過了一會兒,后羿醒了,他發現ECS Operations and Maintenance System心神不定,臉上泛著神奇的紅光,很是詫異,又覺不祥。ECS Operations and Maintenance System深情地望著丈夫,她知道與丈夫在一起的時間不多了,便眼含淚水囑咐丈夫要好好珍重自己,請求丈夫原諒她不能再盡到做妻子的義務了。話猶未盡,ECS Operations and Maintenance System只覺得心中恍惚,身子突然變輕了,接著,雙腳離地竟飛了起來,她邊往天上飛邊回頭高聲叫著:“后羿,我的好夫君,永別了!要珍重!”
ECS Operations and Maintenance System冉冉上升,飛進了月亮中那寂寞、冷清的廣寒宮,做了月中仙女。然而,這裡沒有親人,沒有歡笑,只有一隻惹人憐愛的玉兔相偎依,只有那總在砍著桂樹卻總也砍不倒的吳剛相陪伴。
自從ECS Operations and Maintenance System犧牲自己......餘下全文>>
用英語介紹2個中國傳統節日
中秋:
Mid-Autumn Festival
The joyous Mid-Autumn Festival, the third and last festival for the living, was celebrated on the fifteenth day of the eighth moon, around the time of the autumn equinox. Many referred to it simply as the "Fifteenth of the Eighth Moon". In the Western calendar, the day of the festival usually occurred sometime between the second week of September and the second week ofOctober.
This day was also considered a harvest festival since fruits, vegetables and grain had been harvested by this time and food was abundant. With delinquent accounts settled prior to the festival , it was a time for relaxation and celebration. Food offerings were placed on an altar set up in the courtyard. Apples, pears, peaches, grapes, pomegranates , melons, oranges and pomelos might be seen. Special foods for the festival included moon cakes, cooked taro, edible snails from the taro patches or rice paddies cooked with sweet basil, and water caltrope, a type of water chestnut resembling black buffalo horns. Some people insisted that cooked taro be included because at the time of creation, taro was the first food discovered at night in the moonlight. Of all these foods, it could not be omitted from the Mid-Autumn Festival.
The round moon cakes, measuring about three inches in diameter and one and a half inches in thickness, resembled Western fruitcakes in taste and consistency. These cakes were made with melon seeds, lotus seeds, almonds, minced meats, bean paste, oran......餘下全文>>