zoukankan      html  css  js  c++  java
  • 大数乘法

    Bulls are so much better at math than the cows. They can multiply huge integers together and get perfectly precise answers ... or so they say. Farmer John wonders if their answers are correct. Help him check the bulls' answers. Read in two positive integers (no more than 40 digits each) and compute their product. Output it as a normal number (with no extra leading zeros). 

    FJ asks that you do this yourself; don't use a special library function for the multiplication.

    Input

    * Lines 1..2: Each line contains a single decimal number.

    Output

    * Line 1: The exact product of the two input lines

    Sample Input

    11111111111111
    1111111111

    Sample Output

    12345679011110987654321

    代码:
    import java.math.BigDecimal;
    import java.util.Scanner;
    
    public class Main {
           public static void main(String[] args) {
                 Scanner scan=new Scanner(System.in);
                 BigDecimal a=scan.nextBigDecimal();
                 BigDecimal b=scan.nextBigDecimal();
                 System.out.println(a.multiply(b));
        }
    }
  • 相关阅读:
    配合网页滚屏播放,做解说词
    @enable跟@import注解
    组合注解与元注解
    Spring Aware
    https的设计原理
    用信鸽来解释 HTTPS
    http三次握手四次挥手
    一致性哈希
    redis cluster原理
    redis cluster集群搭建
  • 原文地址:https://www.cnblogs.com/qdu-lkc/p/12189177.html
Copyright © 2011-2022 走看看