NEU 1495 a interesting game 大数 难度:1
问题 G: a interesting game
时间限制: 1 Sec 内存限制: 128 MB
提交: 29 解决: 10
[提交][状态][讨论版]
题目描述
One day,Kid is in class.But Kid think what the teacher teaching is so boring,so he decide to play a
game with himself.He will give himself a matrix with n rows and m columns.Then for each
position,Kid will write 0 or 1 on it.Kid want to find that there are how many schemes that for each
row and each column the number of 1 is odd.
输入
The first line is a integer t,the number of case.
Then for each case,there are two numbers,n and m,(1<=n,m<=100)implies the rows and the columns.
输出
For each case,output only one integer,the number of schemes.
样例输入
1
2 2
样例输出
2
题目链接:http://acm.neu.edu.cn/hustoj/problem.php?cid=1047&pid=6
思考:n行m列,如果n,m奇偶性不同肯定为0,否则前面的随便填充,最后一行一列状态补足条件,也就是2^((n-1)(m-1))
import java.math.BigInteger;
import java.util.Scanner; public class Main {
public static void main(String[] args) throws Exception{
int T;
Scanner in = new Scanner(System.in);
T=in.nextInt();
for(int i=0;i<T;i++){
int n,m;
n=in.nextInt();
m=in.nextInt();
if(n>m){int t=n;n=m;m=t;}
if((n%2==1&&m%2!=1)||(m%2==1&&n%2!=1)){System.out.println("0");continue;}
if(n==1){System.out.println("1");continue;}
int t=(n-1)*(m-1)-1;
BigInteger ans = BigInteger.valueOf(2).shiftLeft(t);
System.out.println(ans);
}
}
}
NEU 1495 a interesting game 大数 难度:1的更多相关文章
- POJ 1503 Integer Inquiry 大数 难度:0
题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...
- NEU 1497 Kid and Ants 思路 难度:0
问题 I: Kid and Ants 时间限制: 1 Sec 内存限制: 128 MB提交: 42 解决: 33[提交][状态][讨论版] 题目描述 Kid likes interest ques ...
- ACM大数模板(支持正负整数)
之前就保留过简陋的几个用外部数组变量实现的简单大数模板,也没有怎么用过,今天就想着整合封装一下,封装成C++的类,以后需要调用的时候也方便得多. 实现了基本的加减乘除和取模运算的操作符重载,大数除以大 ...
- HDU 1495 非常可乐 bfs 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=1495 第三个杯子的盛水量可由前两个杯子得到,而前两个杯子状态总数在100*100以内,穷举可实现 #includ ...
- 快速切题 sgu 111.Very simple problem 大数 开平方 难度:0 非java:1
111.Very simple problem time limit per test: 0.5 sec. memory limit per test: 4096 KB You are given n ...
- POJ 2109 Power of Cryptography 大数,二分,泰勒定理 难度:2
import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger p,l,r,d ...
- NEU 1496 Planar map 计算几何,点到线段距离 难度:0
问题 H: Planar map 时间限制: 1 Sec 内存限制: 128 MB提交: 24 解决: 22[提交][状态][讨论版] 题目描述 Tigher has work for a lon ...
- 快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1
112. a^b-b^a time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given natural num ...
- 51 nod 1495 中国好区间
1495 中国好区间 基准时间限制:0.7 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 阿尔法在玩一个游戏,阿尔法给出了一个长度为n的序列,他认为,一段好的区间,它的长度是& ...
随机推荐
- hihocoder1478 水陆距离
地址:http://hihocoder.com/problemset/problem/1478 题目: 水陆距离 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个 ...
- pigeon 介绍
https://github.com/dianping/pigeon Pigeon开发指南 Pigeon是一个分布式服务通信框架(RPC),在美团点评内部广泛使用,是美团点评最基础的底层框架之一. 主 ...
- Linux 日志分析工具(logwatch)安装及使用
Linux 日志分析工具(logwatch)安装及使用 日志是非常重要的系统文件,管理员每天的重要工作就是分析和查看服务器的日志,判断服务器的健康状态.但是日志管理又是一项非常枯燥的工作,如果需要管理 ...
- genisoimage命令用法
功能说明:建立ISO 9660映像文件. 常用命令:genisoimage -o imagename.iso file 语 法:mkisofs [-adDfhJlLNrRTvz][-print-si ...
- [Face++]Face初探——人脸检测
经过了强烈的思想斗争才把自己拖到图书馆做毕设T^T anyway, 因为毕设里面有人脸识别的部分,所以就想找个现成的api先玩玩,于是就找到最近很火的face++:http://www.faceplu ...
- [日志]logback告警
开发过程中,难免会有发生错误或异常的时候,有些是需要及时通知到相关开发人员的.logback可以通过简单的配置达到邮件告警的目的. 一.错误告警 如下配置,所有Error级别的log发送邮件告警给re ...
- php 安装Memcache扩展
转载地址:http://www.tuicool.com/articles/EB3imm 文章概述:由于当前机器安装的php,是用yum安装,现在需要使用到memadmin做一些监控, memadmin ...
- axios配置大全
一.安装 1. 利用npm安装npm install axios --save 2. 利用bower安装bower install axios --save 3. 直接利用cdn引入<scrip ...
- MR案例:小文件合并SequeceFile
SequeceFile是Hadoop API提供的一种二进制文件支持.这种二进制文件直接将<key, value>对序列化到文件中.可以使用这种文件对小文件合并,即将文件名作为key,文件 ...
- [洛谷P4918]信仰收集
题目背景 随着各种势力的迁入,守矢神社丧失了不少信仰现在,为了挽回香火日益惨淡的神社,八坂神奈子派遣神社的风祝早苗去人类村落收集信仰 题目描述 你可以将村落看成一个m个点的有向无环图(编号从1−m), ...