首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
好矩阵
[编程题]好矩阵
热度指数:557
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
我们定义一个矩阵为“好矩阵”,当且仅当该矩阵所有2*2的子矩阵数字和为偶数。
例如:
是好矩阵,两个2*2的子矩阵的和分别是8和12。
请问
行
列,矩阵中每个数均在
范围内的好矩阵有多少种?由于答案过大,请对
取模。
数据范围:
保证
为偶数。
示例1
输入
2,2,2
输出
8
说明
合法的8个矩阵为:
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(1)
邀请回答
收藏(44)
分享
纠错
提交结果有问题?
8个回答
1篇题解
开通博客
澪语
发表于 2022-09-29 19:14:17
链接 class Solution { public: int mod = 1e9 + 7; int func(long long a, long long b) { long long res = 1; while (b) {
展开全文
问题信息
上传者:
小小
难度:
8条回答
44收藏
4249浏览
热门推荐
通过挑战的用户
pptk
2023-03-07 01:17:08
iloveno...
2023-03-03 17:15:11
牛客40885...
2023-03-01 00:32:47
UPMagic
2023-02-12 10:23:54
月洒心园
2023-02-10 10:24:35
相关试题
在模拟电路中, LC正弦波震荡电路...
模拟电路
评论
(1)
在4层PCB设计中,最优的分层设计...
PCB
评论
(1)
React中的合成事件(Synth...
React
评论
(1)
在下面的 React 组件中,如果...
React
评论
(1)
在处理多语言任务时,以下哪种 Pr...
提示词工程
评论
(1)
好矩阵
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
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