This is a combination of questions. The Chinese question surface should be able to understand, the nonsense does not say more to say this question.
The total number of combinations that can be selected is CK3
So the choice of 3 people is the same, either know, or do not know. Can be considered on the reverse side, is to ask three people are not the same relationship.
Then for the first person has guanxi[1] and he knew there is k-guanxi[1]-1 and he does not know, then the three-person relationship is not the same as the number of species (k-guanxi[1]-1) *guanxi[1];
The same is true for the people who follow.
Finally add these kinds of numbers, there must be duplicates, such as A and b know with C, B and C acquaintance, calculate a when the combination of ABC, calculate the combination of B is 0, calculate C when the combination of CBA,
Then there's the repetition.
Because every two people will only correspond to a relationship so A and b know, in the choice of a when the AB, and then add an unknown C, when choosing B if there is a combination of BAC, then the relationship between C and B is not known, then when the C is selected
It is impossible to choose ABC This combination, if there is ABC in the selection of C, stating that C knows B, then there is no ABC when choosing B. So that is, each combination is repeated to the times, so it must not meet the number/2 is the actual number of non-conformance.
The problem then solves the total number of combinations-the number of actual discrepancies.
Here's a look at the code:
1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <math.h>5typedefLong Longll;6 Doubleguanxi[ -];7 intMainvoid)8 {9 intI,j,k,p,q,n;Ten Doublex, y; Onescanf"%d",&n); A while(n--) - { -scanf"%d",&k); thell dd=0; - for(i=0; i<k; i++) - { -scanf"%LF",&guanxi[i]); +dd+= (k-guanxi[i]-1)*Guanxi[i]; - + } All x1=k* (K-1) * (K-2)/6;//total number of combinations at Doublex2=x1-dd/2;//DD/2 the number of actual discrepancies. -x=1.0*x2/(1.0*x1); -printf"%.3f\n", x); - } - return 0; - in}
HDU 4503 Series Story-Arbor Day (combination probability)