bzoj3680: amputated xxx

Source: Internet
Author: User

Description

Gty and abused a game, the battered Konjac Konjac decided amputated gty. Gty See the trend is not good wit out of n a fen, but still be numbers Konjac Konjac caught. Konjac Konjac will
n a gty hanging on n ropes, each rope passing through a hole in the roof. This n-string has a common knot x. After hanging good gty Konjac Konjac found that because each gty gravity is different, the rope
Knot x is moving. Konjac Konjac WANGXZ The decision to calculate the coordinates of the last stop, because he was too weak to ask you for help.
No friction, no energy loss, because the gty is short enough so will not fall to the ground.

Input

Enter the first behavior a positive integer n (1<=n<=10000) that represents the number of gty.
The next n lines, three integers per line, represent the xi,yi,wi of the gty, the ordinate and the gravity of the first.
For 20% of the data, the gty is arranged in a straight line.
For 50% of data, 1<=n<=1000.
For 100% of data, 1<=n<=10000,-100000<=xi,yi<=100000

Output

Outputs 1 rows of two floating-point numbers (reserved to 3 digits after the decimal point), indicating the horizontal and vertical axis of the final x.

Sample Input3
0 0 1
0 2 1
1 1 1
Sample Output0.577 1.000Exercisesputs ("Nan nan") acWhat is in fact is generalized with the right to charge the horse point, and then bare on the simulated annealing. Code
1#include <cstdio>2#include <iostream>3#include <cmath>4#include <cstring>5#include <algorithm>6 #defineSQR (x) ((x) * (x))7 using namespacestd;8 Charch;9 BOOLOK;Ten voidReadint&x) { One      for(ok=0, Ch=getchar ();! IsDigit (CH); Ch=getchar ())if(ch=='-') ok=1; A      for(x=0; isdigit (ch); x=x*Ten+ch-'0', ch=GetChar ()); -     if(OK) x=-x; - } the voidReadDouble&x) { -      for(ok=0, Ch=getchar ();! IsDigit (CH); Ch=getchar ())if(ch=='-') ok=1; -      for(x=0; isdigit (ch); x=x*Ten+ch-'0', ch=GetChar ()); -     if(OK) x=-x; + } - Const intmaxn=10005; + Const DoublePi=3.14159265358979; A intN; at Doublemaxv=-100000, TX,TY,G[MAXN]; - structpoint{ -     Doublex, y; -     voidInit () {read (x), read (y), Tx+=x,ty+=y,maxv=max (maxv,x), maxv=Max (maxv,y);} - }point[maxn],nxt,ans; - DoubleGetrand () {returnRAND ()%100000/100000.0;} in DoubleCalc (Point t) { -     Doubleres=0; to      for(intI=1; i<=n;i++){ +         DoubleDis=sqrt (Sqr (point[i].x-t.x) +SQR (point[i].y-t.y)); -res+=dis*G[i]; the     } *     returnRes; $ }Panax Notoginseng voidSA () { -      for(DoubleT=maxv,t1=calc (ans), T2; T>0.0000001; t*=0.99){ the         DoubleDeg=getrand () *pi*2, Len=pow (T,2.0/3); +Nxt.x=ans.x+cos (deg) *len,nxt.y=ans.y+sin (deg) *Len; AT2=Calc (NXT); the         if(exp ((T1-T2)/T) >getrand ()) ans=nxt,t1=T2; +     } -printf"%.3LF%.3lf\n", ans.x,ans.y); $ } $ intMain () { -Srand19990617); - read (n); the      for(intI=1; i<=n;i++) Point[i].init (), read (G[i]); -Ans= (point) {tx/n,ty/N},sa ();Wuyi     return 0; the}

bzoj3680: amputated xxx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.