问题 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. 基于EasyUI 快速搭建权限管理平台

    前言: 一.用户角色权限设计思路: <1>不同职责的人员,对于系统操作的权限应该是不同;<2>可以对“组”进行权限分配;<3>权限管理系统应该是可扩展的;<4 ...

  2. VS 和 Eclipse 的一些快捷键记录

    VS: 自动排版: Ctrl+K+F 选项卡之间的切换: Ctrl+Tab 统一缩进: Shift+Tab Ctrl + M + O: 折叠所有方法 Ctrl + M + L: 展开所有方法 Ecli ...

  3. 带你走进ajax(3)

    使用ajax实现用户名有效性验证 需求:当用户输入完用户名时,用户可以通过页面上的按键来确认当前的用户名是否有效.如下图所示 思路:用户触发按键后可以向服务器发起http请求,将用户名提交给服务器来进 ...

  4. 安装vmware虚拟机和linux(centos)

    打开 WMware Workstation 8,然后选择新建虚拟机 2 新建虚拟机向导 选择 自定义(高级)(C)然后点击[下一步]按钮 3 选择虚拟机硬件兼容性 选择 workstation 8.0 ...

  5. python之subprocess

    官网介绍:https://docs.python.org/3/library/subprocess.html Popen(): [root@oracle scripts]# cat sub_popen ...

  6. 解决Android Studio中Rendering Problems错误

    android studio提示错误信息如下图: 解决办法: 打开styles.xml文件 在Theme.AppCompat.Light.DarkActionBar前面加上Base. 修改后解决错误:

  7. 20145307《信息安全系统设计基础》第五周学习总结PT2

    20145307<信息安全系统设计基础>第五周学习总结PT2: 教材学习内容总结 之前有第一部分学习总结: http://www.cnblogs.com/Jclemo/p/5962219. ...

  8. 20145329《Java程序设计》第八周学习总结

    教材学习内容总结 日志 1.java.util.logging包提供了日志功能相关类与接口. 2.使用日志的起点是Logger类,Longer类的构造函数标示为protected,不同包的类药取得Lo ...

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

    20144303 <Java程序设计>第一次实验实验报告 北京电子科技学院(besti)实验报告 课程:java程序设计 班级:1453 指导教师:娄嘉鹏 实验日期:2016.04.08 ...

  10. Spring多开发环境配置

    在项目开发中,多环境的的配置可以方便在不同环境的切换,减少错误的产生 一.properties文件的多环境配置 properties文件可以根据不同的后缀来区分不同的环境 application.pr ...