大数加法,题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002

import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        int count = 1;
        n = sc.nextInt();
        int t=n;
        while (t> 0) {
            BigInteger a = sc.nextBigInteger();
            BigInteger b = sc.nextBigInteger();
            System.out.println("Case " + count+":");
            System.out.println(a + " + " + b + " = " + a.add(b));
            t--;
            if(count!=n)
                System.out.println();
            count++;

        }
    }
}

大数判断(带小数,重要的题目):题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2054

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            BigDecimal a=sc.nextBigDecimal();
            BigDecimal b=sc.nextBigDecimal();
            if(a.compareTo(b)==0) {
                System.out.println("YES");
            }
            else
                System.out.println("NO");

        }
    }
}

大数阶层,题目链接:http://acm.jlnu.edu.cn/problem.php?id=1130

import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        BigInteger n=new BigInteger("1");
        for (int i = 2; i <= 1977; ++i) {
            n = n.multiply(BigInteger.valueOf(i));
        }
            System.out.println(n);
    }
}

大斐波那契,题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1715

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner cin = new Scanner(System.in);

        BigInteger[] nums = new BigInteger[1010];
        nums[1] = new BigInteger("1");
        nums[2] = new BigInteger("1");
        for(int i = 3; i <= 1000; i++)
            nums[i] = nums[i - 1].add(nums[i - 2]);

        int T = cin.nextInt();
        while(T > 0)
        {
            T--;
            int n = cin.nextInt();
            System.out.println(nums[n]);
        }

    }

}

java大数习题的更多相关文章

  1. java大数

    java大数还是很好用的! 基本加入: import java.math.BigInteger; import jave.math.BigDecimal; 分别是大数和大浮点数. 首先读入可以用: S ...

  2. JAVA大数运算

    java大数是个好东西,用起来方便,代码短. 代码如下: import java.util.*; import java.math.*; public class Main { public stat ...

  3. java大数总结【转】

    java大数(2013长春网络赛)--hdu4762总结一下:1.java提交类要写Main.2.读取大数. Scanner read=new Scanner(System.in); BigInteg ...

  4. HDU5047Sawtooth(java大数)

    HDU5047Sawtooth(java大数) 题目链接 题目大意:在一个矩形内画n个"M".问如何画可以把这个矩形分成最多的区域. 给出这个区域的数目. 解题思路:最好的方式就是 ...

  5. JAVA大数类

    JAVA大数类api http://man.ddvip.com/program/java_api_zh/java/math/BigInteger.html#method_summary 不仅仅只能查J ...

  6. HDU4762(JAVA大数)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. ZOJ3477&JAVA大数类

    转:http://blog.csdn.net/sunkun2013/article/details/11822927 import java.util.*; import java.math.BigI ...

  8. 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&amp;记忆化递归

    HDU 4911 Inversion 考点:归并排序 思路:这题呀比赛的时候忘了知道能够用归并排序算出逆序数,可是忘了归并排序的实质了.然后不会做-- 由于看到题上说是相邻的两个数才干交换的时候.感觉 ...

  9. 收藏的一段关于java大数运算的代码

    收藏的一段关于java大数运算的代码: package study_02.number; import java.math.BigDecimal; import java.math.BigIntege ...

随机推荐

  1. 《Java数据结构》链表结构(单向链表,双向链表)

    单向链表(单链表)是链表的一种,其特点是链表的链接方向是单向的,对链表的访问要通过顺序读取从头部开始:链表是使用指针进行构造的列表:又称为结点列表,因为链表是由一个个结点组装起来的:其中每个结点都有指 ...

  2. Redis 底层数据结构介绍

    Redis 底层数据结构 版本:2.9 支持的数据类型: 字符串 散列 列表 集合 有序集合 字符串 Redis 利用原生的 c 字符串进行了一次封装.封装的字符串叫做简单动态字符串:SDS(simp ...

  3. 动态代理模式_应用(Redis工具类)

    本次使用动态代理的初衷是学习Redis,使用Java操作Redis时用到Jedis的JedisPool,而后对Jedis的方法进一步封装完善成为一个工具类.因为直接使用Jedis对象时,为了保证性能, ...

  4. JS---offset系列和scroll系列

    元素的样式属性是无法直接通过:对象.style.属性来获取(样式在style属性中设置)   offset系列: offsetLeft:距离左边位置的值 offsetTop:距离上面位置的值 offs ...

  5. day06数组、数组声明和赋值、数组复制、数组排序

    复习 1.do-while 1)语法 do{ //循环体 }while(<条件>); 2.while和do-while 1)while 先判断,后执行 初始条件不满足,一次都不执行 2)d ...

  6. 最短路径之Dijsktra算法(python)

    定义: 起始位置:A 终止位置:F 持久集合:permanent = set() 暂时集合:temporary = set() 首先将起始位置A加入永久集合,并将A的距离设为0, 此时遍历A的邻接节点 ...

  7. Linux selinux 规则导致audit拒绝

    Linux selinux 规则导致audit拒绝 转载注明来源: 本文链接 来自osnosn的博客,写于 2019-09-26. 查看 audit2why -d audit2allow 这两个命令. ...

  8. jQuery-验证码倒计时的实现

    点击发送验证码,通常需要加入倒计时功能,HTML如下: <center class='block captchaArea'> <input class="input pwd ...

  9. webpack4配置学习(一)

    webpack 是一个现代 JavaScript 应用程序的静态模块打包器(module bundler).当 webpack 处理应用程序时,它会递归地构建一个依赖关系图(dependency gr ...

  10. python高阶函数——map/reduce

    python 内置了map()和reduce()函数 1.map()函数 map()函数接收两个参数,一个是函数,一个是可迭代对象Iterable,map将传入的函数依次作用于序列的每一个元素.并把结 ...