hdu 4919 java大数
来源:互联网 发布:淘宝海报 编辑:程序博客网 时间:2024/05/18 13:26
Exclusive or
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 277 Accepted Submission(s): 107
Problem Description
Given n, find the value of
Note: ⊕ denotes bitwise exclusive-or.
Note: ⊕ denotes bitwise exclusive-or.
Input
The input consists of several tests. For each tests:
A single integer n (2≤n<10500).
A single integer n (2≤n<10500).
Output
For each tests:
A single integer, the value of the sum.
A single integer, the value of the sum.
Sample Input
34
Sample Output
64
Author
Xiaoxu Guo (ftiasch)
Source
2014 Multi-University Training Contest 5
为java记录一下。
import java.math.BigInteger;import java.io.*;import java.util.*;public class Main { public static HashMap<BigInteger,BigInteger> h; public static BigInteger solve(BigInteger n){ if(h.containsKey(n)) return h.get(n); if (n.equals(BigInteger.ZERO)) return BigInteger.ZERO; if (n.equals(BigInteger.ONE)) return BigInteger.ZERO; BigInteger tp; BigInteger tp1=n.divide(BigInteger.valueOf(2)); BigInteger er=BigInteger.valueOf(2); if(n.mod(BigInteger.valueOf(2)).equals(BigInteger.ONE)){ BigInteger tmp=solve(tp1); tp=tmp.multiply(BigInteger.valueOf(4)).add(tp1.multiply(BigInteger.valueOf(6))); } else { BigInteger tmp=solve(tp1); BigInteger tmp1=solve(tp1.subtract(BigInteger.ONE)); tp=tmp.multiply(BigInteger.valueOf(2)).add(tmp1.multiply(BigInteger.valueOf(2))) .add(tp1.multiply(BigInteger.valueOf(4))).subtract(BigInteger.valueOf(4)); } h.put(n,tp); return tp; } public static void main(String[] args){ h=new HashMap<BigInteger, BigInteger>(); Scanner in=new Scanner(System.in); BigInteger n; for(int i=2;i<=10000;i++){ solve(BigInteger.valueOf(i)); } while (in.hasNext()) { n = in.nextBigInteger(); System.out.println(solve(n)); } }}
0 0
- hdu 4919 java大数
- 【java 大数】hdu java 大数
- HDU-4919-数学推导加Java大数
- hdu 4873 Java大数
- hdu 4927 java大数
- HDU-5050 java大数
- HDU-1042(java 大数)
- hdu 2045 java 大数
- hdu 4919 数论+大数
- hdu 1002 java 大数相加
- hdu-1002-Java大数加法
- hdu 1002 Java 大数 加法
- Java 大数加减乘除 hdu 5047
- Java大数求解ACM(HDU)
- hdu 5047 java大数+思维
- hdu 1250 java大数练习
- HDU 2100 Lovekey 大数java
- HDU 4919 打表找规律 java大数 map 递归
- 网页的滚动高度宽度的总结
- MYSQL cmd命令测试
- qsort-sort 排序
- 进化算法、遗传算法与粒子群算法之间的比较
- 【Unity3D自学记录】Unity3D显示NPC名称
- hdu 4919 java大数
- apache 配置 python cgi
- 插件 plugin
- VMware Workstation 与Server 的区别
- 缓慢甚至崩溃
- Latex "参考文献的url太长"问题
- Tomcat6.0的安装配置
- 动态规划经典五题
- oracle 体系结构