• 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 }
  • 相关阅读:
    18个功能强大的HTML5 和JavaScript游戏引擎库
    10 个超棒的 jQuery 视频插件
    HTML5播放视频音频
    CSS代码重构与优化之路
    推荐10款web前端的 HTML5 开发框架和开发工具
    JS中日期相关函数
    技术笔记1:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password)
    图解HTTP阅读笔记(1)-网络基础TCP/IP
    框架和设计模式的区别
    SSH与MVC
  • 原文地址:https://www.cnblogs.com/ZERO-/p/9703212.html
Copyright © 2020-2023  润新知