问题 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的更多相关文章

  1. POJ 1503 Integer Inquiry 大数 难度:0

    题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...

  2. NEU 1497 Kid and Ants 思路 难度:0

    问题 I: Kid and Ants 时间限制: 1 Sec  内存限制: 128 MB提交: 42  解决: 33[提交][状态][讨论版] 题目描述 Kid likes interest ques ...

  3. ACM大数模板(支持正负整数)

    之前就保留过简陋的几个用外部数组变量实现的简单大数模板,也没有怎么用过,今天就想着整合封装一下,封装成C++的类,以后需要调用的时候也方便得多. 实现了基本的加减乘除和取模运算的操作符重载,大数除以大 ...

  4. HDU 1495 非常可乐 bfs 难度:1

    http://acm.hdu.edu.cn/showproblem.php?pid=1495 第三个杯子的盛水量可由前两个杯子得到,而前两个杯子状态总数在100*100以内,穷举可实现 #includ ...

  5. 快速切题 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 ...

  6. POJ 2109 Power of Cryptography 大数,二分,泰勒定理 难度:2

    import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger p,l,r,d ...

  7. NEU 1496 Planar map 计算几何,点到线段距离 难度:0

    问题 H: Planar map 时间限制: 1 Sec  内存限制: 128 MB提交: 24  解决: 22[提交][状态][讨论版] 题目描述 Tigher has work for a lon ...

  8. 快速切题 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 ...

  9. 51 nod 1495 中国好区间

    1495 中国好区间 基准时间限制:0.7 秒 空间限制:131072 KB 分值: 80 难度:5级算法题   阿尔法在玩一个游戏,阿尔法给出了一个长度为n的序列,他认为,一段好的区间,它的长度是& ...

随机推荐

  1. 性能调优之MySQL篇四:MySQL配置定位以及优化

    一.CPU最大性能模式 cpu利用特点 5.1 最高可用4个核 5.5 最高可用24核 5.6 最高可用64核心 一次query对应一个逻辑CPU 你仔细检查的话,有些服务器上会有的一个有趣的现象:你 ...

  2. vuejs模仿实现一个电影分享类网站

    前几天朋友发了一个电影分享类网站:http://dy.bingthink.top/ 感觉界面还挺好看的,所以打算用vuejs模仿写一个. 从后台转前端,要学习的东西挺多的,仅以此记录我的学习历程,闲的 ...

  3. HBase1.2.6 javaapi查看rowkey 所在分区等信息

    Connection connection = HBaseFactory.getIns().getHbaseConn(); RegionLocator r= connection.getRegionL ...

  4. try cath

    用try cath 的缺点? 举例: 一个程序 有3层.基类层,中间层,和  使用层. 在 基类层 使用 try cath 如果发生 异常,将会 一层一层 冒泡到 使用层 并弹出报错信息:效率 大大降 ...

  5. Java读者写者问题

    实验存档. 允许好几个人同时读,但是不允许在有人读的时候写,以及同一时间只能有一个人在写. 读者.java: package operating.entity.readerwriter; import ...

  6. 20145335郝昊 Java学习心得 密码学代码复写

    20145335郝昊 Java学习心得 密码学代码复写 本学期我们学习了现代密码学这门课程,在上课的时候接触到了很多种类型的密码体制,对于一些典型很通用的密码体制有自己的学习和设计.不论是从密码体制还 ...

  7. Vmware 设置桥接模式

    在搭建VMware虚拟机的时候要配置网络 可以看到一共主要就3种 1.桥接模式(Bridge) 虚拟系统的IP可设置成与本机系统在同一网段,虚拟系统相当于网络内的一台.独立的机器,与本机共同插在一个H ...

  8. rhel7配置链路聚合(双网卡热备)

    team方法 1). nmcli connection add type team con-name team0 ifname team0 config '{"runer":{&q ...

  9. VirtualBox安装RedHat7

    软件准备 VirtualBox-5.2.8-121009-Win.exe rhel-server-7.4-x86_64-dvd.iso 安装环境 win10 安装步骤: 1.先在win10系统中安装V ...

  10. Spring核心技术AOP案例

    在SpringAOP开发之前,首先要了解一下这几个概念.Target:目标,通俗的说对哪个类做增强,那个类就是目标.JoinPoint:连接点,在实际开发中可以被增强的点.PointCut:切入点,在 ...