Bzoj 3680 hanging XXX Simulated Annealing

Source: Internet
Author: User

First, the name of this question should be changed to the target person.

Given N points, calculate the center of gravity

The center of gravity of the N points satisfies the minimum x g [I] of Σ (distance from the center of gravity to I ).

Bare questions of Simulated Annealing

Nima handed in two articles and failed to modify various parameters. Finally, I found that my INF was not big enough Nima!

This question INF should be opened 0x3 F... At least max_of _ long_long is required.

At last, 10188 MS was written, and bzoj was the penultimate ...... This is also an art. 0.0

# Include <cmath> # include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # define M 10100 using namespace STD; struct point {Double X, y, G;} points [m], ans; int N; double minans = 23333333333333333ll; double DIS (const point & X, const point & Y) {return SQRT (X. x-y.x) * (X. x-y.x) + (X. y-y.y) * (X. y-y.y);} double judge (const point & P) {int I; double Re = 0; for (I = 1; I <= N; I ++) re + = points [I]. g * Dis (p, points [I]); If (Re <minans) ans = P, minans = Re; return re;} double rand () {return rand () % 1000/1000. 0;} void SA (double T) {int I; point now = ans; while (T> 0.001) {point NEO; Neo. X = now. X + T * (RAND () * 2-1); Neo. y = now. Y + T * (RAND () * 2-1); double de = judge (now)-judge (NEO ); if (de> 0 | exp (DE/T)> rand () now = NEO; T * = 0.993;} for (I = 1; I <= 1000; I ++) {point NEO; Neo. X = ans. X + T * (RAND () * 2-1); Neo. y = ans. Y + T * (RAND () * 2-1); Judge (NEO) ;}} int main () {int I; srand (19970815); CIN> N; for (I = 1; I <= N; I ++) {scanf ("% lf", & points [I]. x, & points [I]. y, & points [I]. g); ans. X + = points [I]. x; ans. Y + = points [I]. y;} ans. x/= N; ans. y/= N; SA (1000000); printf ("%. 3lf %. 3lf \ n ", ans. x, ans. Y );}


Bzoj 3680 hanging XXX Simulated Annealing

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.