Description
Input
Output
Sample Input2 2 1 1 0 0 4 4 3 1 0 0 1 1Sample Output2.00 201.41Solution: Use the method of tolerance, select all cases, for each selected number, find other points to the selected point of the shortest distance and r product, plus, find the minimum value;but always WA, for Mao, the sense of thinking is right;Code:
#include <cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<cstring>#include<queue>using namespacestd;Const intinf=0xFFFFFFF;#defineMem (x, y) memset (x,y,sizeof (x))#defineSI (x) scanf ("%d", &x)#definePI (x) printf ("%d", X)typedefLong LongLL;Const intmaxn= the;DoubleLX[MAXN],LY[MAXN];DoubleMP[MAXN][MAXN];intN;Doubleans;DoubleC,r;DoubleD[MAXN];DoubleGetl (intIintj) { Doubley=ly[j]-ly[i],x=lx[j]-Lx[i]; returnsqrt (x*x+y*y);}voidWork () {ans=INF; for(intI=1;i< (1<<N); i++){ Doubletemp=0; for(intk=0; k<n;k++) d[k]=INF; for(intj=0; j<n;j++){ if(i& (1<<j)) {Temp+=b; for(intk=0; k<n;k++) {D[k]=min (d[k],r*Mp[k][j]); } D[j]=0; //printf ("%d", j); } } //puts (""); for(intI=0; i<n;i++) temp+=D[i]; //for (int k=0;k<n;k++) printf ("D[%d]=%.1lf", K,d[k]);p UTS ("");ans=min (ans,temp); } printf ("%.2f\n", ans);}intMain () {intT; SI (T); while(t--) {scanf ("%D%LF%LF",&n,&c,&s); for(intI=0; i<n;i++) {scanf ("%LF%LF",&lx[i],&Ly[i]); } for(intI=0; i<n;i++) for(intj=i+1; j<n;j++) Mp[i][j]=mp[j][i]=Getl (I,J); Work (); } return 0;}
Communication Base Station (for Mao WA)