首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
好矩阵
[编程题]好矩阵
热度指数:550
时间限制: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收藏
3743浏览
热门推荐
通过挑战的用户
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
相关试题
字符串最后一个单词的长度
字符串
评论
(3575)
来自
2016乐视暑期实习生招...
明明的随机数
数组
评论
(3914)
来自
华为研发工程师编程题
密码验证合格程序
数组
字符串
模拟
评论
(1432)
dota2中,以下哪个英雄不具备隐...
游戏运营
评论
(1)
iOS10以后UIScrollVi...
360集团
iOS
iOS工程师
2018
评论
(1)
来自
360公司-2018春招...
好矩阵
扫描二维码,关注牛客网
意见反馈
下载牛客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