<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ```java package net.zhaoxuyang.common.algorithm.search; /** * 圖的m著色問題 * @author zhaoxuyang */ public class MColoring { public static void main(String[] args) { int n = 5; int m = 5; int[][] a = { {-1, -1, -1, -1, -1, -1}, {-1, 0, 1, 1, 1, 0}, {-1, 1, 0, 1, 1, 1}, {-1, 1, 1, 0, 1, 0}, {-1, 1, 1, 1, 0, 1}, {-1, 0, 1, 0, 1, 0} }; MColoring c = new MColoring(); long sum = c.coloring(m, n, a); System.out.println(sum); } int n; // 圖的頂點數 int m; // 可用的顏色數 int[][] a;//圖的鄰接矩陣 int[] x;//當前解 long sum;//當前已找到的可m著色方案數 public long coloring(int m, int n, int[][] a) { this.n = n; this.a = a; x = new int[n + 1]; this.m = m; sum = 0; backtrack(1); return sum; } private void backtrack(int t) { if (t > n) { sum++; for (int i = 1; i <= n; i++) { visit(x[i]); } System.out.println(); } else { for (int i = 1; i <= m; i++) { x[t] = i; if (ok(t)) { backtrack(t + 1); } x[t] = 0; } } } private void visit(int item) { System.out.printf("%d ", item); } private boolean ok(int k) { for (int j = 1; j <= n; j++) { if (a[k][j] == 1 && x[j] == x[k]) { return false; } } return true; } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看