<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 每個值為 0 或 n 的矩陣的最大行列式 > 原文: [https://www.geeksforgeeks.org/maximum-determinant-matrix-every-values-either-0-n/](https://www.geeksforgeeks.org/maximum-determinant-matrix-every-values-either-0-n/) 我們給定一個正數 n,我們必須找到一個 3 * 3 矩陣,該矩陣可以由 0 或 n 的組合形成,并且具有最大的行列式。 **示例**: ``` Input : n = 3 Output : Maximum determinant = 54 Resultant Matrix : 3 3 0 0 3 3 3 0 3 Input : n = 13 Output : Maximum determinant = 4394 Resultant Matrix : 13 13 0 0 13 13 13 0 13 ``` **解釋**: 對于元素為 0 或 n 的任何 3 * 3 矩陣,最大可能行列式為 **2 *(n ^ 3)。** 。 具有最大行列式的矩陣的形式也為: n n 0 0 n n n 0 0 ## C++ ```cpp // C++ program to find? maximum possible determinant // of 0/n matrix. #include <bits/stdc++.h> using namespace std; // Function for maximum determinant int maxDet(int n) { ????return (2*n*n*n); } // Function to print resulatant matrix void resMatrix ( int n) { ????for (int i = 0; i < 3; i++) ????{ ????????for (int j = 0; j < 3; j++) ????????{ ????????????// three position where 0 appears ????????????if (i == 0 && j == 2) ????????????????cout << "0 "; ????????????else if (i == 1 && j == 0) ????????????????cout << "0 "; ????????????else if (i == 2 && j == 1) ????????????????cout << "0 "; ????????????// position where n appears ????????????else ????????????????cout << n << " "; ????????} ????????cout << "\n"; ????} }? // Driver code int main() { ????int n = 15; ????cout << "Maximum Determinant = " << maxDet(n); ????cout << "\nResultant Matrix :\n"; ????resMatrix(n);? ????return 0; } ``` ## Java ```java // Java program to find maximum possible // determinant of 0/n matrix. import java.io.*; public class GFG { // Function for maximum determinant static int maxDet(int n) { ????return (2 * n * n * n); } // Function to print resulatant matrix void resMatrix(int n) { ????for (int i = 0; i < 3; i++) ????{ ????????for (int j = 0; j < 3; j++) ????????{ ????????????// three position where 0 appears ????????????if (i == 0 && j == 2) ????????????????System.out.print("0 "); ????????????else if (i == 1 && j == 0) ????????????????System.out.print("0 "); ????????????else if (i == 2 && j == 1) ????????????????System.out.print("0 "); ????????????// position where n appears ????????????else ????????????????System.out.print(n +" "); ????????} ????????System.out.println(""); ????} }? ????// Driver code ????static public void main (String[] args) ????{ ????????????int n = 15; ????????????GFG geeks=new GFG(); ????????????System.out.println("Maximum Determinant = " ????????????????????????????????+ maxDet(n)); ????????????System.out.println("Resultant Matrix :");? ????????????geeks.resMatrix(n);? ????} } // This code is contributed by vt_m. ``` ## Python3 ```py # Python 3 program to find maximum # possible determinant of 0/n matrix.? # Function for maximum determinant def maxDet(n): ????return 2 * n * n * n # Function to print resulatant matrix? def resMatrix(n): ????for i in range(3): ????????for j in range(3): ????????????# three position where 0 appears ????????????if i == 0 and j == 2: ????????????????print("0", end = " ") ????????????elif i == 1 and j == 0: ????????????????print("0", end = " ") ????????????elif i == 2 and j == 1: ????????????????print("0", end = " ") ????????????# position where n appears ????????????else: ????????????????print(n, end = " ") ????????print("\n") # Driver code n = 15 print("Maximum Detrminat=", maxDet(n)) print("Resultant Matrix:") resMatrix(n) # This code is contributed by Shrikant13 ``` ## C# ```cs // C# program to find maximum possible // determinant of 0/n matrix. using System; public class GFG { // Function for maximum determinant static int maxDet(int n) { ????return (2 * n * n * n); } // Function to print resulatant matrix void resMatrix(int n) { ????for (int i = 0; i < 3; i++) ????{ ????????for (int j = 0; j < 3; j++) ????????{ ????????????// three position where 0 appears ????????????if (i == 0 && j == 2) ????????????????Console.Write("0 "); ????????????else if (i == 1 && j == 0) ????????????????Console.Write("0 "); ????????????else if (i == 2 && j == 1) ????????????????Console.Write("0 "); ????????????// position where n appears ????????????else ????????????????Console.Write(n +" "); ????????} ????????Console.WriteLine(""); ????} }? ????// Driver code ????static public void Main (String []args) ????{ ????????????int n = 15; ????????????GFG geeks=new GFG(); ????????????Console.WriteLine("Maximum Determinant = " ????????????????????????????????+ maxDet(n)); ????????????Console.WriteLine("Resultant Matrix :");? ????????????geeks.resMatrix(n);? ????} } // This code is contributed by vt_m. ``` ## PHP ```php <?php // PHP program to find maximum? // possible determinant of 0/n matrix. // Function for maximum determinant function maxDet($n) { ????return (2 * $n * $n * $n); } // Function to print? // resulatant matrix function resMatrix ( $n) { ????for ($i = 0; $i < 3; $i++) ????{ ????????for ($j = 0; $j < 3; $j++) ????????{ ????????????// three position? ????????????// where 0 appears ????????????if ($i == 0 && $j == 2) ????????????????echo "0 "; ????????????else if ($i == 1 && $j == 0) ????????????????echo "0 "; ????????????else if ($i == 2 && $j == 1) ????????????????echo "0 "; ????????????// position where n appears ????????????else ????????????????echo $n , " "; ????????} ????echo "\n"; ????} }? // Driver code $n = 15; echo "Maximum Determinant = " ,? ????????????????????maxDet($n); echo "\nResultant Matrix :\n"; resMatrix($n);? // This code is contributed // by nitin mittal.? ?> ``` **輸出**: ``` Maximum Determinant = 6750 Resultant Matrix : 15 15 0 0 15 15 15 0 15 ``` **練習**:將上述解擴展為廣義的 k x k 矩陣。 本文由 [**Shivam Pradhan(anuj_charm)**](https://www.facebook.com/anuj.charm) 提供。 如果您喜歡 GeeksforGeeks 并希望做出貢獻,則還可以使用 [tribution.geeksforgeeks.org](http://www.contribute.geeksforgeeks.org) 撰寫文章,或將您的文章郵寄至 tribution@geeksforgeeks.org。 查看您的文章出現在 GeeksforGeeks 主頁上,并幫助其他 Geeks。
                  <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>

                              哎呀哎呀视频在线观看