zoukankan      html  css  js  c++  java
  • Codeforces Gym100735 I.Yet another A + B-Java大数 (KTU Programming Camp (Day 1) Lithuania, Birˇstonas, August 19, 2015)

    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
    ");
    15   else if((a.add(c)).compareTo(b)==0)System.out.println("YES
    ");
    16   else if((b.add(c)).compareTo(a)==0)System.out.println("YES
    ");
    17   else if((a.add(a)).compareTo(b)==0||(a.add(a)).compareTo(c)==0)System.out.println("YES
    ");
    18   else if((b.add(b)).compareTo(a)==0||(b.add(b)).compareTo(c)==0)System.out.println("YES
    ");
    19   else if((c.add(c)).compareTo(a)==0||(c.add(c)).compareTo(b)==0)System.out.println("YES
    ");
    20   else System.out.println("NO
    ");
    21   }
    22 }
  • 相关阅读:
    自我介绍
    企业级应用与互联网应用差异
    Java EE 目标
    自我评价
    第二周———搜查令
    软件工程项目____搜查令
    结对项目--黄金点游戏(邓乐&曾亮)
    wordcount程序
    四则运算 来自 http://www.cnblogs.com/ys1101/p/4368103.html
    问题
  • 原文地址:https://www.cnblogs.com/ZERO-/p/9703212.html
Copyright © 2011-2022 走看看