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的序列,他认为,一段好的区间,它的长度是& ...
随机推荐
- 字符编码的发展(ASCII、Unicode、utf-8)
最近一直在看廖雪峰老师的python网上教程,python内容简单易理解,就没整理,但是字符串编码作为一直困扰自己的问题,看了几遍文章,最终还是将其整理如下,本篇博客总结自廖雪峰老师的网上教程:htt ...
- std::tuple作为参数invoke调用函数
template<typename Function, typename Tuple, std::size_t... Index> decltype(auto) invoke_impl(F ...
- 《Java程序设计》实验3
20145318 <Java程序设计>实验3 实验内容 使用 git 上传代码 使用 git 相互更改代码 实现代码的重载 PSP 队友链接 http://www.cnblogs.com/ ...
- 20145211 《网络渗透》MS08_067安全漏洞
20145211 <网络渗透>MS08_067安全漏洞 一.实验原理 ms08_067是服务器服务中一个秘密报告的漏洞,于2008年被发现.攻击者利用靶机默认开放的SMB服务的445端口, ...
- Vmware 设置桥接模式
在搭建VMware虚拟机的时候要配置网络 可以看到一共主要就3种 1.桥接模式(Bridge) 虚拟系统的IP可设置成与本机系统在同一网段,虚拟系统相当于网络内的一台.独立的机器,与本机共同插在一个H ...
- GDOI2017 五一游玩记
GDOI2017 到辣! 在五一比赛,成功躲了两天文化课. Day 0 早上睡到挺晚,想着同学在上课,我在睡觉,暗爽... 动车上,拿起电脑就是颓废,打模板!(然而真相是打了两个模板就开始颓了) 一天 ...
- BZOJ 3192: [JLOI2013]删除物品 奇淫技巧&树状数组
点我看题 这题十分奇淫技巧...QAQ因为知道是树状数组的题QAQ刚开始以为维护两个数组的树状数组然后模拟从大到小,然后发现不会打QAQ 于是悄悄咪咪翻开题解了. 实际上两个数组可以看做一个数组 如 ...
- R 中的哪些命令或者包让你相见恨晚?--转载知乎
https://www.zhihu.com/question/24501195 节选: 看了这么多答案,觉得 Hadley Wickhamhad.co.nz 在R使用者的地位好高啊.其实我也觉得Had ...
- 在Jupyter notebook中使用特定虚拟环境中的python的kernel
在虚拟环境tf中安装完tensorflow后,在虚拟环境tf打开的jupyter里发现只有一个kernel-python3,新建一个文件, import tensorflow as tf ,发 ...
- 【Python】模块学习之Timer定时任务,递归定时自调获取博客浏览量
Timer定时任务 下面是Timer函数的官方doc介绍信息 """ Call a function after a specified number of second ...