#include #include #include #include #include #ifdef DEBUG #define DBG(x) x #else #define DBG(x) #endif FILE * in; char names[20][100]; double mat[20][20]; double reach[20][10]; void calc (int i,int j,int bs,int be) { int k; reach[i][j] = 0.0; for (k=bs;k<=be; ++k) reach[i][j] += reach[k][i-1] * mat[i][k] /100.0; reach[i][j] *= reach[i][j-1]; } int main () { int kase=0,i,j; in = fopen ("france98.in", "r"); for (i=0; i<16; ++i) fscanf (in, "%s ", names[i]); for (i=0; i<16; ++i) for (j=0; j<16; ++j) fscanf (in, "%lf ", &(mat[i][j])) ; for (i=0; i<16; ++i) reach[i][0] = 1.0; calc (0,1,1,1); calc (1,1,0,0); calc (2,1,3,3); calc (3,1,2,2); calc (4,1,5,5); calc (5,1,4,4); calc (6,1,7,7); calc (7,1,6,6); calc (8,1,9,9); calc (9,1,8,8); calc (10,1,11,11); calc (11,1,10,10); calc (12,1,13,13); calc (13,1,12,12); calc (14,1,15,15); calc (15,1,14,14); calc (0,2,2,3); calc (1,2,2,3); calc (2,2,0,1); calc (3,2,0,1); calc (4,2,6,7); calc (5,2,6,7); calc (6,2,4,5); calc (7,2,4,5); calc (8,2,10,11); calc (9,2,10,11); calc (10,2,8,9); calc (11,2,8,9); calc (12,2,14,15); calc (13,2,14,15); calc (14,2,12,13); calc (15,2,12,13); calc (0,3,4,7); calc (1,3,4,7); calc (2,3,4,7); calc (3,3,4,7); calc (4,3,0,3); calc (5,3,0,3); calc (6,3,0,3); calc (7,3,0,3); calc (8,3,12,15); calc (9,3,12,15); calc (10,3,12,15); calc (11,3,12,15); calc (12,3,8,11); calc (13,3,8,11); calc (14,3,8,11); calc (15,3,8,11); calc (0,4,8,15); calc (1,4,8,15); calc (2,4,8,15); calc (3,4,8,15); calc (4,4,8,15); calc (5,4,8,15); calc (6,4,8,15); calc (7,4,8,15); calc (8,4,0,7); calc (9,4,0,7); calc (10,4,0,7); calc (11,4,0,7); calc (12,4,0,7); calc (13,4,0,7); calc (14,4,0,7); calc (15,4,0,7); for (i=0; i<16; ++i) printf ("%10sp=%f%%\n", names[i], reach[i][4] * 100.0); return 0; }