#include <bits/stdc++.h> using namespace std; #define endl '\n' #define L long long #define MP make_pair #define REP(i, n) for(int i = 0; i < n; ++i) #define REPR(i, n) for(int i = n - 1; i >= 0; --i) #define FOR(i, a, b) for(int i = a; i < b; ++i) #define FORR(i, a, b) for(int i = b - 1; i >= a; --i) #define EB emplace_back #define ST first #define ND second #define S size #define RS resize template<class T> using P = pair<T, T>; template<class T> using V = vector<T>; int n, m, k = 0; L count_neigh(V<string>& p) { L res = 0; REP(i, n) { REP(j, m) { if (i < n - 1 && p[i][j] + p[i + 1][j] == 'O' + '.') { res++; } if (j < m - 1 && p[i][j] + p[i][j + 1] == 'O' + '.') { res++; } } } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; V<string> p1(n), p2(n); REP(i, n) { cin >> p1[i]; } REP(i, n) { cin >> p2[i]; } int m1 = 0, m2 = 0; REP(i, n) { REP(j, m) { if (p1[i][j] == 'O') { m1 += i + j; k++; } if (p2[i][j] == 'O') { m2 += i + j; } } } if (m1 % 2 != m2 % 2) { cout << 0; return 0; } L res[9][9][9]; L neigh = count_neigh(p2); res[1][2][1] = 1; res[1][3][1] = 2; res[1][3][2] = 2; res[1][4][1] = 3; res[1][4][2] = 6; res[1][4][3] = 3; res[1][5][1] = 4; res[1][5][2] = 12; res[1][5][3] = 12; res[1][5][4] = 4; res[1][6][1] = 5; res[1][6][2] = 20; res[1][6][3] = 30; res[1][6][4] = 20; res[1][6][5] = 5; res[1][7][1] = 6; res[1][7][2] = 30; res[1][7][3] = 60; res[1][7][4] = 60; res[1][7][5] = 30; res[1][7][6] = 6; res[1][8][1] = 7; res[1][8][2] = 42; res[1][8][3] = 105; res[1][8][4] = 140; res[1][8][5] = 105; res[1][8][6] = 42; res[1][8][7] = 7; res[2][1][1] = 1; res[2][2][1] = 4; res[2][2][2] = 8; res[2][2][3] = 4; res[2][3][1] = 7; res[2][3][2] = 28; res[2][3][3] = 42; res[2][3][4] = 28; res[2][3][5] = 7; res[2][4][1] = 10; res[2][4][2] = 60; res[2][4][3] = 150; res[2][4][4] = 200; res[2][4][5] = 150; res[2][4][6] = 60; res[2][4][7] = 10; res[2][5][1] = 13; res[2][5][2] = 104; res[2][5][3] = 364; res[2][5][4] = 728; res[2][5][5] = 910; res[2][5][6] = 728; res[2][5][7] = 364; res[2][5][8] = 104; res[2][6][1] = 16; res[2][6][2] = 160; res[2][6][3] = 720; res[2][6][4] = 1920; res[2][6][5] = 3360; res[2][6][6] = 4032; res[2][6][7] = 3360; res[2][6][8] = 1920; res[2][7][1] = 19; res[2][7][2] = 228; res[2][7][3] = 1254; res[2][7][4] = 4180; res[2][7][5] = 9405; res[2][7][6] = 15048; res[2][7][7] = 17556; res[2][7][8] = 15048; res[2][8][1] = 22; res[2][8][2] = 308; res[2][8][3] = 2002; res[2][8][4] = 8008; res[2][8][5] = 22022; res[2][8][6] = 44044; res[2][8][7] = 66066; res[2][8][8] = 75504; res[3][1][1] = 2; res[3][1][2] = 2; res[3][2][1] = 7; res[3][2][2] = 28; res[3][2][3] = 42; res[3][2][4] = 28; res[3][2][5] = 7; res[3][3][1] = 12; res[3][3][2] = 84; res[3][3][3] = 252; res[3][3][4] = 420; res[3][3][5] = 420; res[3][3][6] = 252; res[3][3][7] = 84; res[3][3][8] = 12; res[3][4][1] = 17; res[3][4][2] = 170; res[3][4][3] = 765; res[3][4][4] = 2040; res[3][4][5] = 3570; res[3][4][6] = 4284; res[3][4][7] = 3570; res[3][4][8] = 2040; res[3][5][1] = 22; res[3][5][2] = 286; res[3][5][3] = 1716; res[3][5][4] = 6292; res[3][5][5] = 15730; res[3][5][6] = 28314; res[3][5][7] = 37752; res[3][5][8] = 37752; res[3][6][1] = 27; res[3][6][2] = 432; res[3][6][3] = 3240; res[3][6][4] = 15120; res[3][6][5] = 49140; res[3][6][6] = 117936; res[3][6][7] = 216216; res[3][6][8] = 308880; res[3][7][1] = 32; res[3][7][2] = 608; res[3][7][3] = 5472; res[3][7][4] = 31008; res[3][7][5] = 124032; res[3][7][6] = 372096; res[3][7][7] = 868224; res[3][7][8] = 1612416; res[3][8][1] = 37; res[3][8][2] = 814; res[3][8][3] = 8547; res[3][8][4] = 56980; res[3][8][5] = 270655; res[3][8][6] = 974358; res[3][8][7] = 2760681; res[3][8][8] = 6310128; res[4][1][1] = 3; res[4][1][2] = 6; res[4][1][3] = 3; res[4][2][1] = 10; res[4][2][2] = 60; res[4][2][3] = 150; res[4][2][4] = 200; res[4][2][5] = 150; res[4][2][6] = 60; res[4][2][7] = 10; res[4][3][1] = 17; res[4][3][2] = 170; res[4][3][3] = 765; res[4][3][4] = 2040; res[4][3][5] = 3570; res[4][3][6] = 4284; res[4][3][7] = 3570; res[4][3][8] = 2040; res[4][4][1] = 24; res[4][4][2] = 336; res[4][4][3] = 2184; res[4][4][4] = 8736; res[4][4][5] = 24024; res[4][4][6] = 48048; res[4][4][7] = 72072; res[4][4][8] = 82368; res[4][5][1] = 31; res[4][5][2] = 558; res[4][5][3] = 4743; res[4][5][4] = 25296; res[4][5][5] = 94860; res[4][5][6] = 265608; res[4][5][7] = 575484; res[4][5][8] = 986544; res[4][6][1] = 38; res[4][6][2] = 836; res[4][6][3] = 8778; res[4][6][4] = 58520; res[4][6][5] = 277970; res[4][6][6] = 1000692; res[4][6][7] = 2835294; res[4][6][8] = 6480672; res[4][7][1] = 45; res[4][7][2] = 1170; res[4][7][3] = 14625; res[4][7][4] = 117000; res[4][7][5] = 672750; res[4][7][6] = 2960100; res[4][7][7] = 10360350; res[4][7][8] = 29601000; res[4][8][1] = 52; res[4][8][2] = 1560; res[4][8][3] = 22620; res[4][8][4] = 211120; res[4][8][5] = 1425060; res[4][8][6] = 7410312; res[4][8][7] = 30876300; res[4][8][8] = 105861600; res[5][1][1] = 4; res[5][1][2] = 12; res[5][1][3] = 12; res[5][1][4] = 4; res[5][2][1] = 13; res[5][2][2] = 104; res[5][2][3] = 364; res[5][2][4] = 728; res[5][2][5] = 910; res[5][2][6] = 728; res[5][2][7] = 364; res[5][2][8] = 104; res[5][3][1] = 22; res[5][3][2] = 286; res[5][3][3] = 1716; res[5][3][4] = 6292; res[5][3][5] = 15730; res[5][3][6] = 28314; res[5][3][7] = 37752; res[5][3][8] = 37752; res[5][4][1] = 31; res[5][4][2] = 558; res[5][4][3] = 4743; res[5][4][4] = 25296; res[5][4][5] = 94860; res[5][4][6] = 265608; res[5][4][7] = 575484; res[5][4][8] = 986544; res[5][5][1] = 40; res[5][5][2] = 920; res[5][5][3] = 10120; res[5][5][4] = 70840; res[5][5][5] = 354200; res[5][5][6] = 1345960; res[5][5][7] = 4037880; res[5][5][8] = 9806280; res[5][6][1] = 49; res[5][6][2] = 1372; res[5][6][3] = 18522; res[5][6][4] = 160524; res[5][6][5] = 1003275; res[5][6][6] = 4815720; res[5][6][7] = 18460260; res[5][6][8] = 58017960; res[5][7][1] = 58; res[5][7][2] = 1914; res[5][7][3] = 30624; res[5][7][4] = 316448; res[5][7][5] = 2373360; res[5][7][6] = 13765488; res[5][7][7] = 64238944; res[5][7][8] = 247778784; res[5][8][1] = 67; res[5][8][2] = 2546; res[5][8][3] = 47101; res[5][8][4] = 565212; res[5][8][5] = 4945605; res[5][8][6] = 33630114; res[5][8][7] = 184965627; res[5][8][8] = 845557152; res[6][1][1] = 5; res[6][1][2] = 20; res[6][1][3] = 30; res[6][1][4] = 20; res[6][1][5] = 5; res[6][2][1] = 16; res[6][2][2] = 160; res[6][2][3] = 720; res[6][2][4] = 1920; res[6][2][5] = 3360; res[6][2][6] = 4032; res[6][2][7] = 3360; res[6][2][8] = 1920; res[6][3][1] = 27; res[6][3][2] = 432; res[6][3][3] = 3240; res[6][3][4] = 15120; res[6][3][5] = 49140; res[6][3][6] = 117936; res[6][3][7] = 216216; res[6][3][8] = 308880; res[6][4][1] = 38; res[6][4][2] = 836; res[6][4][3] = 8778; res[6][4][4] = 58520; res[6][4][5] = 277970; res[6][4][6] = 1000692; res[6][4][7] = 2835294; res[6][4][8] = 6480672; res[6][5][1] = 49; res[6][5][2] = 1372; res[6][5][3] = 18522; res[6][5][4] = 160524; res[6][5][5] = 1003275; res[6][5][6] = 4815720; res[6][5][7] = 18460260; res[6][5][8] = 58017960; res[6][6][1] = 60; res[6][6][2] = 2040; res[6][6][3] = 33660; res[6][6][4] = 359040; res[6][6][5] = 2782560; res[6][6][6] = 16695360; res[6][6][7] = 80694240; res[6][6][8] = 322776960; res[6][7][1] = 71; res[6][7][2] = 2840; res[6][7][3] = 55380; res[6][7][4] = 701480; res[6][7][5] = 6488690; res[6][7][6] = 46718568; res[6][7][7] = 272524980; res[6][7][8] = 1323692760; res[6][8][1] = 82; res[6][8][2] = 3772; res[6][8][3] = 84870; res[6][8][4] = 1244760; res[6][8][5] = 13381170; res[6][8][6] = 112401828; res[6][8][7] = 768079158; res[6][8][8] = 4389023760; res[7][1][1] = 6; res[7][1][2] = 30; res[7][1][3] = 60; res[7][1][4] = 60; res[7][1][5] = 30; res[7][1][6] = 6; res[7][2][1] = 19; res[7][2][2] = 228; res[7][2][3] = 1254; res[7][2][4] = 4180; res[7][2][5] = 9405; res[7][2][6] = 15048; res[7][2][7] = 17556; res[7][2][8] = 15048; res[7][3][1] = 32; res[7][3][2] = 608; res[7][3][3] = 5472; res[7][3][4] = 31008; res[7][3][5] = 124032; res[7][3][6] = 372096; res[7][3][7] = 868224; res[7][3][8] = 1612416; res[7][4][1] = 45; res[7][4][2] = 1170; res[7][4][3] = 14625; res[7][4][4] = 117000; res[7][4][5] = 672750; res[7][4][6] = 2960100; res[7][4][7] = 10360350; res[7][4][8] = 29601000; res[7][5][1] = 58; res[7][5][2] = 1914; res[7][5][3] = 30624; res[7][5][4] = 316448; res[7][5][5] = 2373360; res[7][5][6] = 13765488; res[7][5][7] = 64238944; res[7][5][8] = 247778784; res[7][6][1] = 71; res[7][6][2] = 2840; res[7][6][3] = 55380; res[7][6][4] = 701480; res[7][6][5] = 6488690; res[7][6][6] = 46718568; res[7][6][7] = 272524980; res[7][6][8] = 1323692760; res[7][7][1] = 84; res[7][7][2] = 3948; res[7][7][3] = 90804; res[7][7][4] = 1362060; res[7][7][5] = 14982660; res[7][7][6] = 128850876; res[7][7][7] = 901956132; res[7][7][8] = 5282885916; res[7][8][1] = 97; res[7][8][2] = 5238; res[7][8][3] = 138807; res[7][8][4] = 2405988; res[7][8][5] = 30676347; res[7][8][6] = 306763470; res[7][8][7] = 2505235005; res[7][8][8] = 17178754320; res[8][1][1] = 7; res[8][1][2] = 42; res[8][1][3] = 105; res[8][1][4] = 140; res[8][1][5] = 105; res[8][1][6] = 42; res[8][1][7] = 7; res[8][2][1] = 22; res[8][2][2] = 308; res[8][2][3] = 2002; res[8][2][4] = 8008; res[8][2][5] = 22022; res[8][2][6] = 44044; res[8][2][7] = 66066; res[8][2][8] = 75504; res[8][3][1] = 37; res[8][3][2] = 814; res[8][3][3] = 8547; res[8][3][4] = 56980; res[8][3][5] = 270655; res[8][3][6] = 974358; res[8][3][7] = 2760681; res[8][3][8] = 6310128; res[8][4][1] = 52; res[8][4][2] = 1560; res[8][4][3] = 22620; res[8][4][4] = 211120; res[8][4][5] = 1425060; res[8][4][6] = 7410312; res[8][4][7] = 30876300; res[8][4][8] = 105861600; res[8][5][1] = 67; res[8][5][2] = 2546; res[8][5][3] = 47101; res[8][5][4] = 565212; res[8][5][5] = 4945605; res[8][5][6] = 33630114; res[8][5][7] = 184965627; res[8][5][8] = 845557152; res[8][6][1] = 82; res[8][6][2] = 3772; res[8][6][3] = 84870; res[8][6][4] = 1244760; res[8][6][5] = 13381170; res[8][6][6] = 112401828; res[8][6][7] = 768079158; res[8][6][8] = 4389023760; res[8][7][1] = 97; res[8][7][2] = 5238; res[8][7][3] = 138807; res[8][7][4] = 2405988; res[8][7][5] = 30676347; res[8][7][6] = 306763470; res[8][7][7] = 2505235005; res[8][7][8] = 17178754320; res[8][8][1] = 112; res[8][8][2] = 6944; res[8][8][3] = 211792; res[8][8][4] = 4235840; res[8][8][5] = 62478640; res[8][8][6] = 724752224; res[8][8][7] = 6885146128; res[8][8][8] = 55081169024; cout << fixed << setprecision(17); cout << (double)neigh / (double)res[n][m][k]; } // g++ -std=c++20 -Wall -Wextra -Wshadow -Wconversion -D_GLIBCXX_DEBUG wie2.cpp -o wie2
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | #include <bits/stdc++.h> using namespace std; #define endl '\n' #define L long long #define MP make_pair #define REP(i, n) for(int i = 0; i < n; ++i) #define REPR(i, n) for(int i = n - 1; i >= 0; --i) #define FOR(i, a, b) for(int i = a; i < b; ++i) #define FORR(i, a, b) for(int i = b - 1; i >= a; --i) #define EB emplace_back #define ST first #define ND second #define S size #define RS resize template<class T> using P = pair<T, T>; template<class T> using V = vector<T>; int n, m, k = 0; L count_neigh(V<string>& p) { L res = 0; REP(i, n) { REP(j, m) { if (i < n - 1 && p[i][j] + p[i + 1][j] == 'O' + '.') { res++; } if (j < m - 1 && p[i][j] + p[i][j + 1] == 'O' + '.') { res++; } } } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; V<string> p1(n), p2(n); REP(i, n) { cin >> p1[i]; } REP(i, n) { cin >> p2[i]; } int m1 = 0, m2 = 0; REP(i, n) { REP(j, m) { if (p1[i][j] == 'O') { m1 += i + j; k++; } if (p2[i][j] == 'O') { m2 += i + j; } } } if (m1 % 2 != m2 % 2) { cout << 0; return 0; } L res[9][9][9]; L neigh = count_neigh(p2); res[1][2][1] = 1; res[1][3][1] = 2; res[1][3][2] = 2; res[1][4][1] = 3; res[1][4][2] = 6; res[1][4][3] = 3; res[1][5][1] = 4; res[1][5][2] = 12; res[1][5][3] = 12; res[1][5][4] = 4; res[1][6][1] = 5; res[1][6][2] = 20; res[1][6][3] = 30; res[1][6][4] = 20; res[1][6][5] = 5; res[1][7][1] = 6; res[1][7][2] = 30; res[1][7][3] = 60; res[1][7][4] = 60; res[1][7][5] = 30; res[1][7][6] = 6; res[1][8][1] = 7; res[1][8][2] = 42; res[1][8][3] = 105; res[1][8][4] = 140; res[1][8][5] = 105; res[1][8][6] = 42; res[1][8][7] = 7; res[2][1][1] = 1; res[2][2][1] = 4; res[2][2][2] = 8; res[2][2][3] = 4; res[2][3][1] = 7; res[2][3][2] = 28; res[2][3][3] = 42; res[2][3][4] = 28; res[2][3][5] = 7; res[2][4][1] = 10; res[2][4][2] = 60; res[2][4][3] = 150; res[2][4][4] = 200; res[2][4][5] = 150; res[2][4][6] = 60; res[2][4][7] = 10; res[2][5][1] = 13; res[2][5][2] = 104; res[2][5][3] = 364; res[2][5][4] = 728; res[2][5][5] = 910; res[2][5][6] = 728; res[2][5][7] = 364; res[2][5][8] = 104; res[2][6][1] = 16; res[2][6][2] = 160; res[2][6][3] = 720; res[2][6][4] = 1920; res[2][6][5] = 3360; res[2][6][6] = 4032; res[2][6][7] = 3360; res[2][6][8] = 1920; res[2][7][1] = 19; res[2][7][2] = 228; res[2][7][3] = 1254; res[2][7][4] = 4180; res[2][7][5] = 9405; res[2][7][6] = 15048; res[2][7][7] = 17556; res[2][7][8] = 15048; res[2][8][1] = 22; res[2][8][2] = 308; res[2][8][3] = 2002; res[2][8][4] = 8008; res[2][8][5] = 22022; res[2][8][6] = 44044; res[2][8][7] = 66066; res[2][8][8] = 75504; res[3][1][1] = 2; res[3][1][2] = 2; res[3][2][1] = 7; res[3][2][2] = 28; res[3][2][3] = 42; res[3][2][4] = 28; res[3][2][5] = 7; res[3][3][1] = 12; res[3][3][2] = 84; res[3][3][3] = 252; res[3][3][4] = 420; res[3][3][5] = 420; res[3][3][6] = 252; res[3][3][7] = 84; res[3][3][8] = 12; res[3][4][1] = 17; res[3][4][2] = 170; res[3][4][3] = 765; res[3][4][4] = 2040; res[3][4][5] = 3570; res[3][4][6] = 4284; res[3][4][7] = 3570; res[3][4][8] = 2040; res[3][5][1] = 22; res[3][5][2] = 286; res[3][5][3] = 1716; res[3][5][4] = 6292; res[3][5][5] = 15730; res[3][5][6] = 28314; res[3][5][7] = 37752; res[3][5][8] = 37752; res[3][6][1] = 27; res[3][6][2] = 432; res[3][6][3] = 3240; res[3][6][4] = 15120; res[3][6][5] = 49140; res[3][6][6] = 117936; res[3][6][7] = 216216; res[3][6][8] = 308880; res[3][7][1] = 32; res[3][7][2] = 608; res[3][7][3] = 5472; res[3][7][4] = 31008; res[3][7][5] = 124032; res[3][7][6] = 372096; res[3][7][7] = 868224; res[3][7][8] = 1612416; res[3][8][1] = 37; res[3][8][2] = 814; res[3][8][3] = 8547; res[3][8][4] = 56980; res[3][8][5] = 270655; res[3][8][6] = 974358; res[3][8][7] = 2760681; res[3][8][8] = 6310128; res[4][1][1] = 3; res[4][1][2] = 6; res[4][1][3] = 3; res[4][2][1] = 10; res[4][2][2] = 60; res[4][2][3] = 150; res[4][2][4] = 200; res[4][2][5] = 150; res[4][2][6] = 60; res[4][2][7] = 10; res[4][3][1] = 17; res[4][3][2] = 170; res[4][3][3] = 765; res[4][3][4] = 2040; res[4][3][5] = 3570; res[4][3][6] = 4284; res[4][3][7] = 3570; res[4][3][8] = 2040; res[4][4][1] = 24; res[4][4][2] = 336; res[4][4][3] = 2184; res[4][4][4] = 8736; res[4][4][5] = 24024; res[4][4][6] = 48048; res[4][4][7] = 72072; res[4][4][8] = 82368; res[4][5][1] = 31; res[4][5][2] = 558; res[4][5][3] = 4743; res[4][5][4] = 25296; res[4][5][5] = 94860; res[4][5][6] = 265608; res[4][5][7] = 575484; res[4][5][8] = 986544; res[4][6][1] = 38; res[4][6][2] = 836; res[4][6][3] = 8778; res[4][6][4] = 58520; res[4][6][5] = 277970; res[4][6][6] = 1000692; res[4][6][7] = 2835294; res[4][6][8] = 6480672; res[4][7][1] = 45; res[4][7][2] = 1170; res[4][7][3] = 14625; res[4][7][4] = 117000; res[4][7][5] = 672750; res[4][7][6] = 2960100; res[4][7][7] = 10360350; res[4][7][8] = 29601000; res[4][8][1] = 52; res[4][8][2] = 1560; res[4][8][3] = 22620; res[4][8][4] = 211120; res[4][8][5] = 1425060; res[4][8][6] = 7410312; res[4][8][7] = 30876300; res[4][8][8] = 105861600; res[5][1][1] = 4; res[5][1][2] = 12; res[5][1][3] = 12; res[5][1][4] = 4; res[5][2][1] = 13; res[5][2][2] = 104; res[5][2][3] = 364; res[5][2][4] = 728; res[5][2][5] = 910; res[5][2][6] = 728; res[5][2][7] = 364; res[5][2][8] = 104; res[5][3][1] = 22; res[5][3][2] = 286; res[5][3][3] = 1716; res[5][3][4] = 6292; res[5][3][5] = 15730; res[5][3][6] = 28314; res[5][3][7] = 37752; res[5][3][8] = 37752; res[5][4][1] = 31; res[5][4][2] = 558; res[5][4][3] = 4743; res[5][4][4] = 25296; res[5][4][5] = 94860; res[5][4][6] = 265608; res[5][4][7] = 575484; res[5][4][8] = 986544; res[5][5][1] = 40; res[5][5][2] = 920; res[5][5][3] = 10120; res[5][5][4] = 70840; res[5][5][5] = 354200; res[5][5][6] = 1345960; res[5][5][7] = 4037880; res[5][5][8] = 9806280; res[5][6][1] = 49; res[5][6][2] = 1372; res[5][6][3] = 18522; res[5][6][4] = 160524; res[5][6][5] = 1003275; res[5][6][6] = 4815720; res[5][6][7] = 18460260; res[5][6][8] = 58017960; res[5][7][1] = 58; res[5][7][2] = 1914; res[5][7][3] = 30624; res[5][7][4] = 316448; res[5][7][5] = 2373360; res[5][7][6] = 13765488; res[5][7][7] = 64238944; res[5][7][8] = 247778784; res[5][8][1] = 67; res[5][8][2] = 2546; res[5][8][3] = 47101; res[5][8][4] = 565212; res[5][8][5] = 4945605; res[5][8][6] = 33630114; res[5][8][7] = 184965627; res[5][8][8] = 845557152; res[6][1][1] = 5; res[6][1][2] = 20; res[6][1][3] = 30; res[6][1][4] = 20; res[6][1][5] = 5; res[6][2][1] = 16; res[6][2][2] = 160; res[6][2][3] = 720; res[6][2][4] = 1920; res[6][2][5] = 3360; res[6][2][6] = 4032; res[6][2][7] = 3360; res[6][2][8] = 1920; res[6][3][1] = 27; res[6][3][2] = 432; res[6][3][3] = 3240; res[6][3][4] = 15120; res[6][3][5] = 49140; res[6][3][6] = 117936; res[6][3][7] = 216216; res[6][3][8] = 308880; res[6][4][1] = 38; res[6][4][2] = 836; res[6][4][3] = 8778; res[6][4][4] = 58520; res[6][4][5] = 277970; res[6][4][6] = 1000692; res[6][4][7] = 2835294; res[6][4][8] = 6480672; res[6][5][1] = 49; res[6][5][2] = 1372; res[6][5][3] = 18522; res[6][5][4] = 160524; res[6][5][5] = 1003275; res[6][5][6] = 4815720; res[6][5][7] = 18460260; res[6][5][8] = 58017960; res[6][6][1] = 60; res[6][6][2] = 2040; res[6][6][3] = 33660; res[6][6][4] = 359040; res[6][6][5] = 2782560; res[6][6][6] = 16695360; res[6][6][7] = 80694240; res[6][6][8] = 322776960; res[6][7][1] = 71; res[6][7][2] = 2840; res[6][7][3] = 55380; res[6][7][4] = 701480; res[6][7][5] = 6488690; res[6][7][6] = 46718568; res[6][7][7] = 272524980; res[6][7][8] = 1323692760; res[6][8][1] = 82; res[6][8][2] = 3772; res[6][8][3] = 84870; res[6][8][4] = 1244760; res[6][8][5] = 13381170; res[6][8][6] = 112401828; res[6][8][7] = 768079158; res[6][8][8] = 4389023760; res[7][1][1] = 6; res[7][1][2] = 30; res[7][1][3] = 60; res[7][1][4] = 60; res[7][1][5] = 30; res[7][1][6] = 6; res[7][2][1] = 19; res[7][2][2] = 228; res[7][2][3] = 1254; res[7][2][4] = 4180; res[7][2][5] = 9405; res[7][2][6] = 15048; res[7][2][7] = 17556; res[7][2][8] = 15048; res[7][3][1] = 32; res[7][3][2] = 608; res[7][3][3] = 5472; res[7][3][4] = 31008; res[7][3][5] = 124032; res[7][3][6] = 372096; res[7][3][7] = 868224; res[7][3][8] = 1612416; res[7][4][1] = 45; res[7][4][2] = 1170; res[7][4][3] = 14625; res[7][4][4] = 117000; res[7][4][5] = 672750; res[7][4][6] = 2960100; res[7][4][7] = 10360350; res[7][4][8] = 29601000; res[7][5][1] = 58; res[7][5][2] = 1914; res[7][5][3] = 30624; res[7][5][4] = 316448; res[7][5][5] = 2373360; res[7][5][6] = 13765488; res[7][5][7] = 64238944; res[7][5][8] = 247778784; res[7][6][1] = 71; res[7][6][2] = 2840; res[7][6][3] = 55380; res[7][6][4] = 701480; res[7][6][5] = 6488690; res[7][6][6] = 46718568; res[7][6][7] = 272524980; res[7][6][8] = 1323692760; res[7][7][1] = 84; res[7][7][2] = 3948; res[7][7][3] = 90804; res[7][7][4] = 1362060; res[7][7][5] = 14982660; res[7][7][6] = 128850876; res[7][7][7] = 901956132; res[7][7][8] = 5282885916; res[7][8][1] = 97; res[7][8][2] = 5238; res[7][8][3] = 138807; res[7][8][4] = 2405988; res[7][8][5] = 30676347; res[7][8][6] = 306763470; res[7][8][7] = 2505235005; res[7][8][8] = 17178754320; res[8][1][1] = 7; res[8][1][2] = 42; res[8][1][3] = 105; res[8][1][4] = 140; res[8][1][5] = 105; res[8][1][6] = 42; res[8][1][7] = 7; res[8][2][1] = 22; res[8][2][2] = 308; res[8][2][3] = 2002; res[8][2][4] = 8008; res[8][2][5] = 22022; res[8][2][6] = 44044; res[8][2][7] = 66066; res[8][2][8] = 75504; res[8][3][1] = 37; res[8][3][2] = 814; res[8][3][3] = 8547; res[8][3][4] = 56980; res[8][3][5] = 270655; res[8][3][6] = 974358; res[8][3][7] = 2760681; res[8][3][8] = 6310128; res[8][4][1] = 52; res[8][4][2] = 1560; res[8][4][3] = 22620; res[8][4][4] = 211120; res[8][4][5] = 1425060; res[8][4][6] = 7410312; res[8][4][7] = 30876300; res[8][4][8] = 105861600; res[8][5][1] = 67; res[8][5][2] = 2546; res[8][5][3] = 47101; res[8][5][4] = 565212; res[8][5][5] = 4945605; res[8][5][6] = 33630114; res[8][5][7] = 184965627; res[8][5][8] = 845557152; res[8][6][1] = 82; res[8][6][2] = 3772; res[8][6][3] = 84870; res[8][6][4] = 1244760; res[8][6][5] = 13381170; res[8][6][6] = 112401828; res[8][6][7] = 768079158; res[8][6][8] = 4389023760; res[8][7][1] = 97; res[8][7][2] = 5238; res[8][7][3] = 138807; res[8][7][4] = 2405988; res[8][7][5] = 30676347; res[8][7][6] = 306763470; res[8][7][7] = 2505235005; res[8][7][8] = 17178754320; res[8][8][1] = 112; res[8][8][2] = 6944; res[8][8][3] = 211792; res[8][8][4] = 4235840; res[8][8][5] = 62478640; res[8][8][6] = 724752224; res[8][8][7] = 6885146128; res[8][8][8] = 55081169024; cout << fixed << setprecision(17); cout << (double)neigh / (double)res[n][m][k]; } // g++ -std=c++20 -Wall -Wextra -Wshadow -Wconversion -D_GLIBCXX_DEBUG wie2.cpp -o wie2 |