solution.cpp 600 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <iostream>
using namespace std;
double rate[4][4] = {
    {0, 0.1, 0.3, 0.5},
    {0.9, 0, 0.7, 0.4},
    {0.7, 0.3, 0, 0.2},
    {0.5, 0.6, 0.8, 0}};

int main()
{
    int i, j, k;
    double time, sum;
    time = 0;
    sum = 0;
    for (i = 1; i < 4; i++)
    {
        for (j = 1; j < 4; j++)
        {
            for (k = 1; k < 4; k++)
            {
                if (j != i && k != i && j != k)
                {
                    sum += rate[0][i] * rate[j][k] * rate[0][j];
                }
            }
        }
        time++;
    }
    cout << sum / time;
    return 0;
}