九度oj-1037-Powerful Calculator
2015-11-14 21:52
225 查看
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:1823
解决:530
题目描述:
Today, facing the rapid development of business, SJTU recognizes that more powerful calculator should be studied, developed and appeared in future market shortly. SJTU now invites you attending such amazing research and development work.
In most business applications, the top three useful calculation operators are Addition (+), Subtraction (-) and Multiplication (×) between two given integers. Normally, you may think it is just a piece of cake. However, since some integers for calculation
in business application may be very big, such as the GDP of the whole world, the calculator becomes harder to develop.
For example, if we have two integers 20 000 000 000 000 000 and 4 000 000 000 000 000, the exact results of addition, subtraction and multiplication are:
20000000000000000 + 4000000000000000 = 24 000 000 000 000 000
20000000000000000 - 4000000000000000 = 16 000 000 000 000 000
20000000000000000 × 4000000000000000 = 80 000 000 000 000 000 000 000 000 000 000
Note: SJTU prefers the exact format of the results rather than the float format or scientific remark format. For instance, we need "24000000000000000" rather than 2.4×10^16.
As a programmer in SJTU, your current task is to develop a program to obtain the exact results of the addition (a + b), subtraction (a - b) and multiplication (a × b) between two given integers a and b.
输入:
Each case consists of two separate lines where the first line gives the integer a and the second gives b (|a| <10^400 and |b| < 10^400).
输出:
For each case, output three separate lines showing the exact results of addition (a + b), subtraction (a - b) and multiplication (a × b) of that case, one result per lines.
样例输入:
样例输出:
来源:2007年上海交通大学计算机研究生机试真题
内存限制:32 兆
特殊判题:否
提交:1823
解决:530
题目描述:
Today, facing the rapid development of business, SJTU recognizes that more powerful calculator should be studied, developed and appeared in future market shortly. SJTU now invites you attending such amazing research and development work.
In most business applications, the top three useful calculation operators are Addition (+), Subtraction (-) and Multiplication (×) between two given integers. Normally, you may think it is just a piece of cake. However, since some integers for calculation
in business application may be very big, such as the GDP of the whole world, the calculator becomes harder to develop.
For example, if we have two integers 20 000 000 000 000 000 and 4 000 000 000 000 000, the exact results of addition, subtraction and multiplication are:
20000000000000000 + 4000000000000000 = 24 000 000 000 000 000
20000000000000000 - 4000000000000000 = 16 000 000 000 000 000
20000000000000000 × 4000000000000000 = 80 000 000 000 000 000 000 000 000 000 000
Note: SJTU prefers the exact format of the results rather than the float format or scientific remark format. For instance, we need "24000000000000000" rather than 2.4×10^16.
As a programmer in SJTU, your current task is to develop a program to obtain the exact results of the addition (a + b), subtraction (a - b) and multiplication (a × b) between two given integers a and b.
输入:
Each case consists of two separate lines where the first line gives the integer a and the second gives b (|a| <10^400 and |b| < 10^400).
输出:
For each case, output three separate lines showing the exact results of addition (a + b), subtraction (a - b) and multiplication (a × b) of that case, one result per lines.
样例输入:
20000000000000000 4000000000000000
样例输出:
24000000000000000 16000000000000000 80000000000000000000000000000000
来源:2007年上海交通大学计算机研究生机试真题
import java.util.Scanner; import java.math.BigInteger; public class Main{ public static void main(String[] args){ Scanner in=new Scanner(System.in); while(in.hasNext()){ BigInteger a=in.nextBigInteger(); BigInteger b=in.nextBigInteger(); System.out.println(a.add(b)); System.out.println(a.subtract(b)); System.out.println(a.multiply(b)); } in.close(); } }
相关文章推荐
- 九度1526
- 九度1025:最大报销额 java
- 九度 题目1026:又一版 A+B java
- 【九度】题目1006:ZOJ问题
- 【九度】题目1005:Graduate Admission
- 【九度】题目1004:Median
- 【九度】题目1003:A+B
- 【九度】题目1002:Grading
- 【九度】题目1001:A+B for Matrices
- 【九度】题目1000:计算a+b
- 三、Hash练习_1156_1
- 三、Hash_1081_1
- 给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。
- 并查集
- JOBDU Q1001
- JOBDU Q1002
- JOBDU Q1003
- JOBDU Q1004
- 九度题目1431解
- 九度--第1001题:A+B for Matrices