问题 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. ionic 打包

    比如我下载一个官方的小Demoionic start myApp tabs(我默认你已经配置好了安卓的开发环境.安装了全局的ionic.cordova)   首先,你需要给项目添加安卓平台的支持ion ...

  2. The 15th UESTC Programming Contest Preliminary J - Jermutat1on cdoj1567

    地址:http://acm.uestc.edu.cn/#/problem/show/1567 题目: Jermutat1on Time Limit: 3000/1000MS (Java/Others) ...

  3. git 提交和下载代码

    在github下需先 New repository 下载:进入程序工程目录下 如 cd f: cd ./Program\ Files/eclipse/workspace/IMoocMusic/ git ...

  4. windows下mysql安装失败的一个解决案例

    操作系统:windows8.1,之前安装过mysql,这次安装在配置的最后一部执行“Apply security settings”的过程中弹出经典错误: Access denied for user ...

  5. git删除本地分支和删除远程分支

    引言: 切换分支的时候命令打错了,git checkout 后面没有跟分支名,结果git status,很多delete的文件,直接冒冷汗,git add ,commit 之后发现本地与远程确实是删除 ...

  6. python3 使用opencv 画基本图形

    在Python3 环境下安装opencv-python 后练习画基本图形: import numpy as np import cv2 # BGR format GREEN = (0, 255, 0) ...

  7. Session管理之超时设置和强制下线

    关于Session,在Java Web开发中,为我们提供了很多方便,Session是由浏览器和服务器之间维护的.好吧,闲话不多说,下面让我们一步一步来实现它们. (一)首先来说下Session超时时间 ...

  8. 20145310 《Java程序设计》第1周学习总结

    20145310 <Java程序设计>第1周学习总结 教材学习内容总结 第一周主要学习教材前两章的知识.第一章主要学习了java的历史,版本的迁移以及一些相关的专有名词之间的联系和下载安装 ...

  9. 解决java.lang.IllegalArgumentException: Can't load standard profile: LINEAR_RGB.pf

    调用org.apache.batik.transcoder.Transcoder转换图片时,报了以下错误:java.lang.IllegalArgumentException: Can't load ...

  10. [BZOJ1217]消防局的设立

    Description 2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地.起初为了节约材料,人类只修建了n-1条道路来 连接这些基地,并且每两个基地都能够通过道路到达,所以所有的基地形成 ...