Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
4
Indexable
Never
# include <bits/stdc++.h>

int cnt [10] ;

int main ( )  {

    for (int a = 0 ; a <= 7 ; ++ a)
        for (int b = 0 ; a + b <= 7 ; ++ b)
            for (int c = 0 ; a + b + c <= 7 ; ++ c)
                for (int d = 0 ; a + b + c + d <= 7 ; ++ d)
                    for (int e = 0 ; a + b + c + d + e <= 7 ; ++ e)
                        for (int f = 0 ; a + b + c + d + e + f <= 7 ; ++ f)
                            for (int g = 0 ; a + b + c + d + e + f + g <= 7 ; ++ g)
                                if (a + b + c + d + e + f + g == 7)  {
                                    int sum = 0 ;
                                    if (a != 0)  sum ++ ;
                                    if (b != 0)  sum ++ ;
                                    if (c != 0)  sum ++ ;
                                    if (d != 0)  sum ++ ;
                                    if (e != 0)  sum ++ ;
                                    if (f != 0)  sum ++ ;
                                    if (g != 0)  sum ++ ;
                                    ++ cnt [sum] ;
                                }
    
    for (int i = 1 ; i <= 7 ; ++ i)  printf ("%d ", cnt [i]) ;
    puts ("") ;
    int tot = 0 ;
    for (int i = 1 ; i <= 7 ; ++ i)  tot += cnt [i] ;

    double ans = 0 ;
    for (int i = 1 ; i <= 7 ; ++ i)  {
        ans += ((double) i / 7.0) * (1.0 * cnt [i] / ((double) tot)) ;
    }
    printf ("%f\n", ans) ;
}