-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1337.cpp
189 lines (180 loc) · 3.19 KB
/
1337.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**************************************************************
* Problem: 1337
* Author: Vanilla_chan
* Date: 20210323
* E-Mail: [email protected]
**************************************************************/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<limits.h>
#define IL inline
#define re register
#define LL long long
#define ULL unsigned long long
#ifdef TH
#define debug printf("Now is %d\n",__LINE__);
#else
#define debug
#endif
#ifdef ONLINE_JUDGE
char buf[1<<23],* p1=buf,* p2=buf,obuf[1<<23],* O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
using namespace std;
namespace oi
{
inline bool isdigit(const char& ch)
{
return ch<='9'&&ch>='0';
}
inline bool isalnum(const char& ch)
{
return (ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9');
}
struct istream
{
char ch;
bool fu;
template<class T>inline istream& operator>>(T& d)
{
fu=d=0;
while(!isdigit(ch)&&ch!='-') ch=getchar();
if(ch=='-') fu=1,ch=getchar();
d=ch-'0';ch=getchar();
while(isdigit(ch))
d=(d<<3)+(d<<1)+(ch^'0'),ch=getchar();
if(fu) d=-d;
return *this;
}
inline istream& operator>>(string& str)
{
str.clear();
for(;!isdigit(ch);ch=getchar());
while(isalnum(ch))
str+=ch,ch=getchar();
return *this;
}
}cin;
inline int read()
{
int x=0,fu=1;
char ch=getchar();
while(!isdigit(ch)&&ch!='-') ch=getchar();
if(ch=='-') fu=-1,ch=getchar();
x=ch-'0';ch=getchar();
while(isdigit(ch)) { x=x*10+ch-'0';ch=getchar(); }
return x*fu;
}
int G[55];
template<class T>inline void write(T x)
{
int g=0;
if(x<0) x=-x,putchar('-');
do { G[++g]=x%10;x/=10; } while(x);
for(int i=g;i>=1;--i)putchar('0'+G[i]);putchar('\n');
}
};
using namespace oi;
int n;
struct vec
{
double x,y;
vec(double xx=0,double yy=0)
{
x=xx;
y=yy;
}
double size()
{
return sqrt(x*x+y*y);
}
vec operator+(const vec& z)
{
return vec(x+z.x,y+z.y);
}
vec operator-(const vec& z)
{
return vec(x-z.x,y-z.y);
}
vec operator+=(const vec& z)
{
x+=z.x;
y+=z.y;
return *this;
}
vec operator-=(const vec& z)
{
x-=z.x;
y-=z.y;
return *this;
}
vec operator*(const double& z)
{
return vec(x*z,y*z);
}
vec operator*=(const double& z)
{
return *this=*this*z;
}
};
vec operator*(const double& b,const vec& a)
{
return vec(a.x*b,a.y*b);
}
struct Thing
{
vec xy;
double z;
void in()
{
xy.x=read();
xy.y=read();
z=read();
}
}thing[2000];
#define down 0.95;
vec ans,last;
bool dX,dY;
const double eps=1e-5;
double T=1000;
void calc()
{
vec t,d;
for(int i=1;i<=n;i++)
{
t=ans-thing[i].xy;
if(t.size()==0) continue;
d+=thing[i].z/t.size()*(thing[i].xy-ans);
}
ans+=T/d.size()*d;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=read();
for(int i=1;i<=n;i++) thing[i].in();
while(1)
{
//cout<<ans.x<<" "<<ans.y<<endl;
last=ans;
calc();
if((ans-last).size()<=eps) break;
if(dX!=(ans.x>last.x)||dY!=(ans.y>last.y))
{
dX=!(ans.x>last.x);
dY=!(ans.y>last.y);
T*=down;
}
}
printf("%.3lf %.3lf",ans.x,ans.y);
return 0;
}