A-a+-b
Time Limit:20 Sec
Memory limit:256 MB
Topic Connection
Http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/A
Description
You are given the integer numbers A and B. Output A + b or A - B.
Input
The first line contains and numbers a, B separeted by A single Space ( -263≤ a B < 2).
Output
Output One integer number: a + b or a - B.
Sample Input
15 27
Sample Output
42
HINT
Test instructions
Give you a A, B, let you output a+b or a-a, you need to ensure that the output value is an integer
The following:
High-precision, then the output of the smallest is good.
Use Java = =
Code:
Import java.util.*; Import java.io.*; Import Java.math.*; Public classMain { Public Static voidmain (String [] args) {Scannerinch=NewScanner (System.inch); BigInteger a=inch. Nextbiginteger (); BigInteger b=inch. Nextbiginteger (); BigInteger C=A.add (b); BigInteger D=A.subtract (b); BigInteger F; BigInteger Kiss; Kiss= Biginteger.valueof (0); F= Biginteger.valueof (-1); intTest =D.compareto (Kiss); if(Test = =-1) d=d.multiply (f); Test=C.compareto (d); if(Test = =1) System. out. println (a.subtract (b)); ElseSystem. out. println (A.add (b)); } }
Codeforces Gym 100418A a-a+-b Java High precision