Machine Equipment (DFS)

Source: Internet
Author: User

Machine Equipment Time limit: ms | Memory limit:65535 KB Difficulty:2
Describe

Alpha Company designed an energy-efficient machine. Its internal structure is made up of N gears. The entire machine has a drive gear, and when it is started, it immediately rotates clockwise at 10,000 laps/hour, and then it drives the opposite direction of the gear that it is tangent to, that is, counterclockwise rotation. The gears interact with each other, each of which can drive multiple gears and ultimately drive a working gear to complete the task. In this set of devices, the center coordinate and the gear radius of each gear are recorded. The known drive gear is located (0,0) and the final working gear is located (Xt, Yt). Alpha wants to know the speed of all gears in the transmission sequence. The so-called transmission sequence, that is, the energy from the drive gear transmission, the last to reach the work of the gear used in the process of all gears. The energy transfer process is driven by a gear with a radius of R and a rotation speed of S/h, and its tangent radius of R ' is-s*r/r ' rpm. The minus sign means that it rotates in the opposite direction.

It is known that in addition to the drive gears, all gears may be driven by another gear, and No 2 different gears will be present to drive the same gear. Your task is to calculate the sum of the energy of all gears in the entire transmission sequence. That is, the sum of the absolute values of all gear speeds.

Input
The
first line: T means the following have T Group test data (1≤T≤8) for each group of test data: line 1th: N Xt Yt (2≤n≤1100) Next has n lines, Xi Yi Ri represents the coordinates and radius of n gears i=1,2,...., N (-500 0≤xi, yi≤5000 3≤ri≤1000) coordinates and the radius is an integer
Output
each set of test data, the output is one line, that is, the absolute value of all gear speed is within the double range, the output integer part
Sample input
14 32 540 30 200 0 1032 54 20-40 30 20
Sample output
20000
Problem: Water problems, the game on the team to write this question, WA to the end, I did not see, down a bit on the
Code:
#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<stack>using namespacestd;structpoint{intx, y; intR;} dt[ -];BOOLJS (Point A, point B) {DoubleL = (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-b.y); if(Fabs (sqrt (1.0*L)-(A.R + B.R)) <0.000000001)return true; Else return false;}intmp[ -][ -];intvis[ -];Doubleans;intstart, end;voidDfsintUDoubleEngDoubletot) {Vis[u]=1; if(U = =end) {ans=tot; return; }     for(inti =0; I < -; i++){        if(Mp[u][i] &&!Vis[i]) {DFS (I, Eng*DT[U].R/DT[I].R, tot + eng*dt[u].r/DT[I].R); }    }}intMain () {intT; scanf ("%d", &T); intN;    Point e;  while(t--) {scanf ("%d%d%d", &n, &e.x, &e.y); Memset (MP,0,sizeof(MP));  for(inti =0; i < N; i++) {scanf ("%d%d%d", &dt[i].x, &AMP;DT[I].Y, &DT[I].R); if(dt[i].x = = e.x && Dt[i].y = =e.y) End=i; if(dt[i].x = =0&& Dt[i].y = =0) Start=i; }         for(inti =0; i < N; i++){             for(intj = i +1; J < N; J + +){                if(JS (Dt[i], dt[j])) {//printf ("%d%d\n", I, j);MP[I][J] = Mp[j][i] =1; }}} ans=0; memset (Vis,0,sizeof(VIS)); DFS (Start,10000,10000); printf ("%d\n", (int) ans); }    return 0;}

Machine Equipment (DFS)

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.