Bull Math(java大数相乘)
2014-10-03 14:18
211 查看
Link:点击打开链接
Problem:
import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Main{
public static void main(String[] args)
{
BigInteger x,y,ans;
Scanner cin=new Scanner(System.in);
while(cin.hasNext())
{
x=cin.nextBigInteger();
y=cin.nextBigInteger();
ans=x.multiply(y);
System.out.println(ans);
}
}
}
Problem:
Bull Math
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 Source USACO 2004 November |
import java.io.*;
import java.math.*;
import java.text.*;
public class Main{
public static void main(String[] args)
{
BigInteger x,y,ans;
Scanner cin=new Scanner(System.in);
while(cin.hasNext())
{
x=cin.nextBigInteger();
y=cin.nextBigInteger();
ans=x.multiply(y);
System.out.println(ans);
}
}
}
相关文章推荐
- POJ 2389 Bull Math(水~Java -大数相乘)
- 大数相乘、大数相加、大数相减Java版本
- Java之数组计算大数相乘
- 两个大数相乘JAVA版
- POJ 2389 Bull Math(大数乘法,还是Java好)
- 数相乘、大数相加、大数相减Java版本
- 大数相乘 (JAVA版)
- java大数相乘算法
- 大数相乘 java
- JAVA 大数相乘
- 大数相乘、大数相加、大数相减Java版本
- Java处理两个大数相乘
- JAVA大数相乘
- 大数算法 -- 正整数相乘(Java 实现)
- JAVA两个大数相乘
- java版大数相乘
- 浅谈一下大数相乘有关思路(图解)与用java代码具体解决方案
- 华为上机测试题(大数相乘-java)
- Java实现大数相乘
- Java实现两个大数相乘