Codeforces Gym100735 I.Yet another A + B-Java大数 (KTU Programming Camp (Day 1) Lithuania, Birˇstonas, August 19, 2015)
2024-08-28 22:32:23
I.Yet another A + B
You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct?
Input
There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10100), each on a separate line of input.
Output
either "YES if there is a way to substitute variables A, B and C with given numbers so the equality is correct, or "NO"otherwise.
Examples
input
1 2 3
output
YES
input
1 2 4
output
YES
input
1 3 5
output
NO
大数计算,给出的数任选2个相加能否等于第三个数或者重复选1个数相加是否等于剩下的2个中的1个,因为是大数,所以直接用Java写的,偷懒专用,哈哈哈哈哈哈。
代码:
1 import java.util.Scanner;
2
3 public class BigInteger {
4 private static Scanner cin;
5
6 public static void main(String[] args) {
7 cin = new Scanner(System.in);
8 java.math.BigInteger a;
9 java.math.BigInteger b;
10 java.math.BigInteger c;
11 a = cin.nextBigInteger();
12 b = cin.nextBigInteger();
13 c = cin.nextBigInteger();
14 if((a.add(b)).compareTo(c)==0)System.out.println("YES\n");
15 else if((a.add(c)).compareTo(b)==0)System.out.println("YES\n");
16 else if((b.add(c)).compareTo(a)==0)System.out.println("YES\n");
17 else if((a.add(a)).compareTo(b)==0||(a.add(a)).compareTo(c)==0)System.out.println("YES\n");
18 else if((b.add(b)).compareTo(a)==0||(b.add(b)).compareTo(c)==0)System.out.println("YES\n");
19 else if((c.add(c)).compareTo(a)==0||(c.add(c)).compareTo(b)==0)System.out.println("YES\n");
20 else System.out.println("NO\n");
21 }
22 }
最新文章
- JavaScript设计模式学习笔记
- Unity中使用多构造函数(转)
- LeetCode - Minimum Depth of Binary Tree
- springMVC-HelloWorld
- 畅通工程再续(MST)
- const C语言(转)
- Entity Framework 学习初级篇--EntityClient(转)
- accessor method &; mutator method
- dubbo管理控制台安装和使用
- poj 1328 Radar Installation(贪心)
- 打印web页面指定区域的三种方法
- crawler_JVM_DNS_在爬虫中的应用
- OpenCV框架介绍
- Android: DrawerLayout 侧滑菜单栏
- 微信小程序,前端大梦想(八)
- 工作流程,编程,调试,性能:Unity游戏开发者应该学习的20个改进技巧
- iOS下JS与OC互相调用(八)--Cordova详解+实战
- 【转】sentry 实时事件日志聚合平台
- oracle常用系统函数
- MySQL实现按天统计数据的方法
热门文章
- usb gadge驱动设计之我是zero
- printf(";\033[1;33m ***** \033[0m \n";);
- Kubespray部署Kubernetes 1.13.0(使用本地镜像仓库)
- python双向链表的疑问(Question)
- java高级编程技巧
- 怕忘记-windows 2003服务器安装Node.js NPM
- WEBs
- 【Decode Ways】cpp
- leetcode 【 Reverse Nodes in k-Group 】 python 实现
- 【Remove Nth Node From End of List】cpp