Description
An advertisement channel adopts a new advertising system. Each advertisement has a given value. The system always selects the most valuable advertisement from the existing one for broadcasting. The system receives a new advertisement every second from the start of the operation. The advertisement will be changed only when the value of the new advertisement is greater than that of the original one.
Now, the value of the advertisement received within n seconds starting from the system is presented in chronological order. It is required to calculate the expected number of actually played ads and the number of played ads for the ad channel during this period.
-
Input
-
The first line is an integer T, indicating that there are T groups of data:
There are two rows for each data set: the first row is a positive integer n (n ≤ 1,000,000) indicating the system running time, and the second row has n integers, the number of I represents the value of the second when an advertisement is received.
-
Output
-
For each group of test data, two rows are output: the first row is an integer representing the number of actually played ads, and the second row is a real number representing the expected number of played ads (three decimal places are expected ).
-
Sample Input
-
21105448456 2746865872 354878401
-
Sample output
-
11.00011.500
simple question simulation and expectation
# include
int main () {int N; int I, j; int X; long int now; int count; long int y; double total; int K; scanf ("% d", & N); for (I = 0; I
now) {now = y; count ++ ;}} printf ("% d \ n", count); Total = 0; For (k = 1; k <= X; k ++) Total + = (double) (1)/K; printf ("%. 3lf \ n ", total);} return 0 ;}