问题 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. 滑块控件CCControlSlider

    #include "cocos-ext.h" //包含头文件 using namespace cocos2d::extension;//引用命名空间 /** * 创建CCContr ...

  2. 20145316许心远《Java程序设计》第4周学习总结

    20145316许心远<Java程序设计>第4周学习总结 教材学习内容总结 6.继承与多态 1.继承共同行为 * 多个类中存在相同属性和行为时,将这些内容抽取到单独一个类中,那么多个类无需 ...

  3. 多路选择I/O

    多路选择I/O提供另一种处理I/O的方法,相比于传统的I/O方法,这种方法更好,更具有效率.多路选择是一种充分利用系统时间的典型. 1.多路选择I/O的概念 当用户需要从网络设备上读数据时,会发生的读 ...

  4. ss+proxifier灵活控制网络代理

    SS相比大家都知道,不多说. proxifier可能知道的不是很多(至少在今天之前我是不知道的...可能我孤陋寡闻吧) 之前用ss基本上就是chrome SwitchyOmega+SS实现chrome ...

  5. Java硬件同步机制Swap指令模拟+记录型信号量模拟

    学校实验存档//.. 以经典的生产者消费者问题作为背景. 进程同步方式接口: package method; /** * P表示通过,V表示释放 */ public interface Method ...

  6. 【Error】安装程序无法打开注册表项 UNKNOWN\Components\...

    在安装程序的时候出现错误信息: 解决方法: 依次点击开始,所有程序,附件,右键单击命令提示符,选择以管理员身份运行.运行secedit /configure /cfg %windir%\inf\def ...

  7. spring cloud要点简介及常用组件

    spring cloud基于spring boot spring cloud是通过包装其他技术框架实现的,例如OSS组件,实现了一套通过基于注解.java配置和基于模板开发的微服务框架. spring ...

  8. 《Java程序设计》第一次实验实验报告

    北京电子科技学院(besti)实验报告 课程:java程序设计 班级:1453 指导教师:娄嘉鹏 实验日期:2016.04.08 实验名称:java开发环境的熟悉(linux + eclipse) 程 ...

  9. 20144303 《Java程序设计》第三周学习总结

    20144303 <Java程序设计>第三周学习总结 教材学习内容总结 •对象是存在的具体实体,具有明确的状态和行为,类是具有相同属性和行为的一组对象的集合,用于组合各个对象所共有操作和属 ...

  10. c语言数组拷贝

    #include <string.h> // 如果要从数组a复制k个元素到数组b,可以这样做 memcpy(b,a,sizeof(int)*k);