【发布时间】:2018-07-16 21:07:16
【问题描述】:
如何找到填充网格 (3*n) 数组的方法数,用 A、B 和 C 三种颜色填充。
在以下限制条件下:
1) All the n cells of the same row can't have the same color.
2)All the 3 cells of the same column can't have the same color.
示例输入:如果 n=2,则输出或路数 = 174。
请解释一下这个方法。
【问题讨论】:
-
你试过 n=1 吗?我没有计算 n=2,但我认为结果不是 174。
-
我遇到了这个问题,当我出现在 Codenation 的技术轮中并且 n=2 时,输出为 174 ,如示例案例中所示
-
@Ante 你能为上述更新的问题提供解决方案吗?
-
@Enigma 这是math.stackexchange.com 的问题。用inclusion-exclusion principle解决。
标签: c++ algorithm matrix dynamic-programming combinatorics