博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Gym 100418A A - A+-B java高精度
阅读量:6977 次
发布时间:2019-06-27

本文共 1181 字,大约阅读时间需要 3 分钟。

A - A+-B

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

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 two numbers AB separeted by a single space ( - 263 ≤ A, B < 263).

Output

Output one integer number: A + B or A - B.

Sample Input

15 27

Sample Output

42

HINT

 

题意

给你a,b,让你输出a+b或者a-b,需要保证输出的值是一个integer

题解

高精度一下,然后输出最小的就好了

用的JAVA = =

代码:

import java.util.*;   import java.io.*;   import java.math.*;     public class Main  {      public static void main(String [] args)      {          Scanner in = new Scanner(System.in);          BigInteger a = in.nextBigInteger();          BigInteger b = in.nextBigInteger();          BigInteger c = a.add(b);        BigInteger d = a.subtract(b);        BigInteger f;        BigInteger kiss;        kiss = BigInteger.valueOf(0);        f = BigInteger.valueOf(-1);        int test = d.compareTo(kiss);        if( test == -1 )            d = d.multiply(f);        test = c.compareTo(d);        if( test == 1 )            System.out.println(a.subtract(b));        else            System.out.println(a.add(b));    }  }

 

转载地址:http://xtupl.baihongyu.com/

你可能感兴趣的文章
esxi4.1使用IDE格式磁盘
查看>>
刚学习了linux的DHCP 配置.呵呵.自己上来总结下.
查看>>
利用windows 2003实现服务器群集的搭建与架设(一) NLB群集的创建与架设
查看>>
pangolin最新版 v2.5.2.975
查看>>
zabbix之日志文件监控
查看>>
组策略 从入门到精通(二) 如何区别跨越WAN网的计算机对组策略的套用
查看>>
Microsoft Dynamics CRM server 2013 中业务规则,有点像C#的正则表达式
查看>>
快速构建Windows 8风格应用27-漫游应用数据
查看>>
flume源码学习8-hdfs sink的具体写入流程
查看>>
Metasploit攻击Oracle的环境搭建
查看>>
Microsoft Office Communications Server 2007 R2 RTM 简体中文企业版部署速成篇之二
查看>>
ASP.net:添加.net(2.0C#)FCKeditor在线编辑器步骤
查看>>
使用Mono管理Coyote Linux
查看>>
公有云环境下应用程序的自动化部署与水平扩展问题
查看>>
JAVAEclipse:could not find the main class,program will exit!
查看>>
Provisioning Services 7.8 入门系列教程之十三 使用 Boot Device Management(BDM)
查看>>
Centos 6.4下MySQL备份及还原详情介绍
查看>>
sql server 表索引碎片处理
查看>>
ASP网络编程从入门到精通 下载
查看>>
集群概述及原理笔记(1)
查看>>