【polya】 HDOJ Count the Tetris
2015-09-03 18:33
176 查看
套用polya计算出奇偶,旋转,反射16种情况的方案数。。
import java.util.*; import java.io.*; import java.math.*; import java.lang.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); int a, b; while(cin.hasNext()) { a = cin.nextInt(); b = cin.nextInt(); BigInteger ans = BigInteger.ZERO; BigInteger tt = BigInteger.valueOf(b); if(a % 2 == 0) { BigInteger t = BigInteger.ONE; for(int i = 1; i <= a * a; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a) / 4; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a) / 4; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); } else { BigInteger t = BigInteger.ONE; for(int i = 1; i <= a * a; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + 3) / 4; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + 1) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + 3) / 4; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); t = BigInteger.ONE; for(int i = 1; i <= (a * a + a) / 2; i++) t = t.multiply(tt); ans = ans.add(t); } ans = ans.divide(BigInteger.valueOf(8)); System.out.println(ans.toString()); } } }
相关文章推荐
- LNK2005错误 :error LNK2005: 已经在 libcmtd.lib(dbgheap.obj) 中定义
- 2012-2013 ACM-ICPC, NEERC, Central Subregional Contest J Computer Network1 (缩点+最远点对)
- Thymeleaf模板引擎 学习笔记
- XMPP的定义及简单介绍
- 【JavaScript中的正则表达式】
- What does “%.*s” mean in printf?
- C++基础---string类的clear/erase/pop_back
- hdu~4282(数学题)
- Access-based enumeration in Windows Server 2012
- Java基础-内部类及其应用
- 不用堆栈实现树的先序遍历
- C++基础---string类的find/find_first_of/find_first_not_of/rfind/find_last_of/find_last_not_of
- PCIe 驱动流程(LTSSM)
- 阻塞与非阻塞,同步与异步
- 定位
- sql server 2012 报表开发(4) Reporting Service 行转列方法
- ATS 5.3.0中parent.config配置文件解读
- JavaScript进阶
- CPlus的简单线程的制作
- 扩展欧几里得算法