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));
        }
    }
  • 相关阅读:
    我的学习记录-JAVA SE 03
    我的学习记录-JAVA SE 02
    我的学习记录-JAVA SE 01
    我的mysql的学习记录
    Hibernate4学习一
    java3
    java5
    java基础4
    java2
    java
  • 原文地址:https://www.cnblogs.com/qdu-lkc/p/12189177.html
Copyright © 2011-2022 走看看