luckygirl4 | |
Usaco Chain Link Chain Link Fence
07:00, 1970-Jan-1
.. 0 comments
.. Link
Inscribe Chain Link Fence3 about this, sigh with emotion extremely: Title: Farmer makes an appointment with writing to had decided to build electrified wire netting. He has enclosed his farm into a few odd form, must find out the optimal position that puts power supply now. Must pull an electrical wiring from power source to every paragraphs of electrified wire netting. Electrical wiring can cross other electrified wire netting to perhaps had crossed other wire. Electrical wiring can with aleatoric angle laid, receive the random of a paragraph of electrified wire netting to went up repeatedly from power source (namely, the end points of this paragraph of electrified wire netting go up or went up in the random between its) . What say here " a paragraph of electrified wire netting " those who point to is the electrified wire netting that submits form of a line segment, not be a few paragraphs of electrified wire netting that are together repeatedly. If a few paragraphs of electrified wire netting are connected together, also should provide electric power to these electrified wire netting respectively so. Foregone all F (1 <= F <= 150) paragraph the position of electrified wire netting (electrified wire netting always is mixed reference axis is parallel, and the coordinate of end points always is integral, 0 <= X, y <= 100) . The smallest overall length of the electrical wiring that your program wants computation to join place of power source and every paragraphs of electrified wire netting needs is spent, still have the optimal coordinate of power source. The optimal coordinate of power source may arrange the any place in the farm of writing in farmer, not be integral certainly. PROGRAM NAME: Chain Link Fence3 INPUT FORMAT F of draw together of the first luggage -- the amount of electrified wire netting. The F below includes two X every rows all right, y is right, express two end points of this paragraph of electrified wire netting. OUTPUT FORMAT Have group only, export 3 float check the number, photograph adjacent two between take a blank space. Assume the output library of your computer is opposite correctly fraction has to pouch nearest whole number. These 3 number are: The X of optimal coordinate is worth power source, pouch belt Y of optimal coordinate is worth power source, spend with the overall length of the electrical wiring of need (should the smallest) . 3 0 0 0 1 2 0 2 1 0 3 2 31.0 1.6 3.7 is forced to the subject violent search, but should use turn the imitate anneal in saying (won't) , the course is improved, be in every time - search in 1~1, find an optimum solution, be in of this optimum solution - search inside 1~1 limits, know to did not produce optimum solution till. Code: Const Z=1e-4;VarX1, x2, y1, y2:aRray[0. .400] Of Real;I, j, f, l:lOngint;An1, an2, max, p, an3, an4:rEal;Function Min(a, b:rEal):rEal;BeginIf A>b Then Exit(b) Else Exit(a);End;function Dis(a1, b1, a2, b2:rEal):rEal;BeginExit(sqrt(sqr(a1-a2) sqr(b1-b2)));End;Function Jisuan(x, y:rEal):rEal;VarI:lOngint;ans, m:rEal;BeginAns:=0;For I:=1 To F DoBeginIf X1[i]=x2[i] ThenBeginIf (y-y1[i])*(y-y2[i])<=z ThenBeginM:=Abs(x-x1[i]);EndElse M:=Min(dis(x, y, x1[i] , y1[i]) , Dis(x, y, x2[i] , y2[i]));EndElse BeginBeginIf (x-x1[i])*(x-x2[i])<=z ThenBeginM:=Abs(y-y1[i]);EndElse M:=Min(dis(x, y, x1[i] , y1[i]) , Dis(x, y, x2[i] , y2[i]));End; End;Ans:=Ans m;End; Exit(ans);End;Procedure Try1;VarI, j:lOngint;BeginMax:=2000000;While (abs(an1-an3)<>0)or(abs(an2-an4)<>0)doBeginAn1:=An3;an2:=An4;For I:=Trunc(an1-l) To Trunc(an1 l) DoFor J:=Trunc(an2-l) To Trunc(an2 l) DoBeginP:=Jisuan(i, j);If P Go helping a center, how does understanding restore a service afresh. Recommend reading articles:
Leave a Comment { Last Page } { Page 5 of 25 } { Next Page } |
About MeMy Profile Archives Friends My Photo Album LinksCategoriesRecent EntriesWhy does of bovine Prince of the Devils tangle soChain Link Fence NAIL IN THE FENCE [Psoriasis] [effect a radical cure psoriasis] psor Memory of @N73 of card of memory of mobile phone o Usaco Chain Link Chain Link Fence Friends |