我们定义一个矩阵为“好矩阵”,当且仅当该矩阵所有2*2的子矩阵数字和为偶数。 例如: 是好矩阵,两个2*2的子矩阵的和分别是8和12。 请问行列,矩阵中每个数均在范围内的好矩阵有多少种?由于答案过大,请对取模。 数据范围: 保证为偶数。
示例1
输入
2,2,2
输出
8
说明
合法的8个矩阵为:
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ public int numsOfGoodMatrix (int n, int m, int x) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ int numsOfGoodMatrix(int n, int m, int x) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @param m int整型 # @param x int整型 # @return int整型 # class Solution: def numsOfGoodMatrix(self , n , m , x ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ public int numsOfGoodMatrix (int n, int m, int x) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ function numsOfGoodMatrix( n , m , x ) { // write code here } module.exports = { numsOfGoodMatrix : numsOfGoodMatrix };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @param m int整型 # @param x int整型 # @return int整型 # class Solution: def numsOfGoodMatrix(self , n: int, m: int, x: int) -> int: # write code here
package main //import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ func numsOfGoodMatrix( n int , m int , x int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ int numsOfGoodMatrix(int n, int m, int x ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @param m int整型 # @param x int整型 # @return int整型 # class Solution def numsOfGoodMatrix(n, m, x) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ def numsOfGoodMatrix(n: Int,m: Int,x: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ fun numsOfGoodMatrix(n: Int,m: Int,x: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ public int numsOfGoodMatrix (int n, int m, int x) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ export function numsOfGoodMatrix(n: number, m: number, x: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ func numsOfGoodMatrix ( _ n: Int, _ m: Int, _ x: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @param m int整型 * @param x int整型 * @return int整型 */ pub fn numsOfGoodMatrix(&self, n: i32, m: i32, x: i32) -> i32 { // write code here } }
2,2,2
8