hdu 4919 ( Exclusive or ) 数论递推
来源:互联网 发布:淘宝网宝贝图片尺寸 编辑:程序博客网 时间:2024/06/05 05:25
Exclusive or
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 223 Accepted Submission(s): 84
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
Recommend
We have carefully selected several similar problems for you: 4920 4918 4917 4916 4915
今天学了java 重写了一遍
import java.util.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); init(); BigInteger N; while(cin.hasNext()) { N = cin.nextBigInteger(); System.out.println(get(N)); } cin.close(); }static Map<BigInteger,BigInteger> map = new HashMap<BigInteger,BigInteger>(); public static void init(){map.put(BigInteger.valueOf(1), BigInteger.valueOf(0));map.put(BigInteger.valueOf(2), BigInteger.valueOf(0));map.put(BigInteger.valueOf(3), BigInteger.valueOf(6));map.put(BigInteger.valueOf(4), BigInteger.valueOf(4));map.put(BigInteger.valueOf(5), BigInteger.valueOf(12));map.put(BigInteger.valueOf(6), BigInteger.valueOf(20));map.put(BigInteger.valueOf(7), BigInteger.valueOf(42));map.put(BigInteger.valueOf(8), BigInteger.valueOf(32));map.put(BigInteger.valueOf(9), BigInteger.valueOf(40));}public static BigInteger get(BigInteger i){BigInteger ret;if(map.containsKey(i)) return map.get(i);else {BigInteger tp= (i.mod(BigInteger.valueOf(2)));if(tp.equals(BigInteger.valueOf(1))){BigInteger ie=i.divide(BigInteger.valueOf(2));ret=(get(ie).multiply(BigInteger.valueOf(4)).add(ie.multiply(BigInteger.valueOf(6))));//get(ie)*4+ie*6;map.put(i, ret);return ret;}else {BigInteger ie=i.divide(BigInteger.valueOf(2));ret=get(ie).add(get(ie.add(BigInteger.valueOf(-1))).add(ie.multiply(BigInteger.valueOf(2))).add(BigInteger.valueOf(-2)));ret=ret.multiply(BigInteger.valueOf(2));map.put(i, ret);return ret;}}}}
0 0
- hdu 4919 ( Exclusive or ) 数论递推
- 【HDU】4919 Exclusive or 推公式+高精度
- HDU 4919 Exclusive or
- hdu 4919 Exclusive or
- hdu 4919 Exclusive or
- hdu 4919 Exclusive or + 高精度板
- [HDU 3234] Exclusive-OR
- hdu 3234 Exclusive-OR
- HDU 3234 Exclusive-OR
- HDU 3234 Exclusive-OR
- HDU4919 Exclusive or(递推+记忆化搜索+大数)
- hdu 1222 (数论+递推)
- HDU4919 Exclusive or(Java大数推公式)
- HDU 4919 Exclusive or 解题报告(规律+大数)
- HDU 4919(Exclusive or-java的HashMap类)
- HDU 3234 Exclusive-OR(并查集)
- Hdu 3234 & Uva 12232 Exclusive-OR
- HDU 3234 - Exclusive-OR(并查集)
- 栈的顺序存储结构及其基本运算实现
- (转+整理)流行RSS频道大全,经典RSS地址
- eclipse build path功能总结
- hdu 1196 Lowest Bit
- 【转载】 最早的体育团体:精武体育会
- hdu 4919 ( Exclusive or ) 数论递推
- 黑马程序员_JAVA对象大小与引用
- Android子线程与主线程通信
- JPA 中的在一个类中 不能够使用多个fetch=FetchType.EAGER 否则会出问题
- javascript jquery 文章地址
- Extjs4.2 +jdbcTemplate 实现的辅助输入,和关联取值功能
- 黑马程序员—字符串String,正则表达式,字符串容器
- 我们需要怎样的 中国式 解说
- 南阳理工_最小乘法次数