-->
当前位置:首页 > 题库

PROGRAMMING:Combination count of triangles

Luz5年前 (2021-05-10)题库428
Triangle is an important foundation of geometry. Almost all geometric problems involve triangles. Many famous theorems can't be proved without triangles, such as some proofs of Butterfly Theorem. Triangles can be combined with many geometric figures to form problems with different degrees of simplicity. At the same time, the properties and theorems of triangles are quite wide, covering geometry and algebra, Functional analysis and so on. Now let's have a simple understanding of triangles
###Suppose that the side lengths of triangles are unequal positive integers, and the maximum side length is n, find the number of these triangles, and output the probability that any three different positive integers from 1 to n can be the three sides of a triangle.
(Note: the three sides of triangle are disordered, such as a, B, C and a, C, B are the same)
(hint: if the middle side length is k, then the value of K is all positive integers in (n / 2, n), and the corresponding minimum side length is all positive integers in (n-k, K))
###Input format:
Enter a positive integer t in one line to indicate the number of test groups, and then enter t in the next line. Each number n represents the corresponding maximum side length of each group of tests( 3 <= n <= 1000) (1 <= T <=3)
###Output format:
For each group of inputs, output the number of triangles in a row, and take any three different integers from 1 to N. they can be the probability of three sides of a triangle, and the probability retains three decimal places.
###Input sample 1:
```in
one
three
```
###Output sample 1:
```out
0 0.000
```
###Input sample 2:
```in
two
4 5
```
###Output sample 2:
```out
1 0.250
3 0.300
```
###Input sample 3:
```in
three
6 67 678
```
###Output sample 3:
```out
7 0.350
23408 0.489
25800047 0.499
```






answer:If there is no answer, please comment