hdu 1041(规律+打表+java大数)
2012-04-04 14:59
441 查看
串中出现01时,在下一步后就会出现连续的两个0
规律:i为偶数时:f[i] = f[i-1] * 2 + 1; i为奇数时:f[i] = f[i-1] * 2 - 1。
规律:i为偶数时:f[i] = f[i-1] * 2 + 1; i为奇数时:f[i] = f[i-1] * 2 - 1。
//规律+打表+java大数 import java.util.Scanner; import java.math.BigInteger; public class CT { public static void main(String args[]) { Scanner cin = new Scanner(System.in); BigInteger []f = new BigInteger[1001]; f[1] = new BigInteger("0"); f[2] = new BigInteger("1"); f[3] = new BigInteger("1"); for (int i=4; i<1001; ++i) { if (i % 2 == 0) { f[i] = f[i-1].multiply(BigInteger.valueOf(2)).add(BigInteger.ONE); } else { f[i] = f[i-1].multiply(BigInteger.valueOf(2)).subtract(BigInteger.ONE); } } int n; while (cin.hasNextInt()) { n = cin.nextInt(); System.out.println(f ); } } }
相关文章推荐
- HDU 4919 打表找规律 java大数 map 递归
- POJ 2680 / ZOJ 2584 : Computer Transformation - 打表+找规律+高精度 / java大数
- hdu 1041 打表:递推+大数 模板
- hdu 1041 Computer Transformation(规律+大数)
- HDU 4002 Find the maximum(JAVA 大数找规律 )
- HDU 4577 - X-Boxes(杭州邀请赛B题)(JAVA大数+规律)
- hdu_1041(Computer Transformation) 大数加法模板+找规律
- hdu 1041(Computer Transformation)(找规律,二维数组大数)
- HDU-1041-Computer Transformation(规律题 && 大数题)
- hdu1041 Computer Transformation 大数找规律
- http://acm.hdu.edu.cn/showproblem.php?pid=2303 (素数打表 + java大数取模)
- 【HDU】1130 - How Many Trees?(java - BigDecimal & 卡特兰大数打表)
- HDU - 4002 Find the maximum (Java大数打表)
- HDU 4919 打表找规律 java睑板 map 递归
- HDU - 6206 Apple 【大数计算之Java】
- HDU-1042(大数阶乘_java)
- HDU-1047-Integer Inquiry(Java大数水题 && 格式恶心)
- HDU 5810 Balls and Boxes(打表找规律)——2016 Multi-University Training Contest 7 1002
- hdoj 1316 How Many Fibs? 【Java大数】+【打表】
- HDU 5429-Geometric Progression(JAVA大数判断等比数列)