标签:log birt diff time decide help not tps point
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4067 Accepted Submission(s): 2171
做法类似POJ2069
请参考:https://www.cnblogs.com/qq965921539/p/9806603.html
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <string> 5 #include <map> 6 #include <set> 7 #include <list> 8 #include <deque> 9 #include <queue> 10 #include <stack> 11 #include <vector> 12 #include <cmath> 13 #include <algorithm> 14 using namespace std; 15 #define it iterator 16 #define ll long long 17 #define eb emplace_back 18 #define lowbit(x) x & -x 19 #define all(x) x.begin(),x.end() 20 #define ZERO(a) memset(a,0,sizeof(a)) 21 #define MINUS(a) memset(a,0xff,sizeof(a)) 22 #define per(x,a,b) for(int x = a; x <= b; x++) 23 #define rep(x,a,b) for(int x = a; x >= b; x--) 24 #define IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) 25 26 const int birth = 19260817; 27 const int mo = 998244353; 28 const int maxn = 1e5 + 10; 29 const int mod = 1e9 + 7; 30 const int INF = 0x3fffffff; 31 const double eps = 1e-8; 32 33 //******************THE PROGRAM BEGINING****************** 34 struct node 35 { 36 double x, y; 37 }p[510],now; 38 39 double dis(node a, node b) 40 { 41 return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2)); 42 } 43 44 double solve(int n) 45 { 46 double ans, cmp; 47 double T = 100.0; 48 double delat = 0.98; 49 now.x = now.y = 0.0; 50 int pos = 0; 51 while (T > eps) 52 { 53 pos = 0; 54 ans = dis(now, p[pos]); 55 per(i, 0, n - 1) 56 { 57 cmp = dis(now, p[i]); 58 if (cmp > ans) 59 { 60 pos = i; 61 ans = cmp; 62 } 63 } 64 now.x += (p[pos].x - now.x) / ans * T; 65 now.y += (p[pos].y - now.y) / ans * T; 66 T *= delat; 67 } 68 return ans; 69 } 70 71 int main() 72 { 73 int n; 74 while (scanf("%d", &n) && n) 75 { 76 per(i, 0, n - 1) 77 scanf("%lf %lf", &p[i].x, &p[i].y); 78 double ans = solve(n); 79 printf("%.2lf %.2lf %.2lf\n", now.x, now.y, ans); 80 } 81 return 0; 82 }
标签:log birt diff time decide help not tps point
原文地址:https://www.cnblogs.com/qq965921539/p/9806780.html