Yet another A + B(高精度问题)

A - Yet another A + B
Time Limit:25000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit

Status

Practice

Gym 100735I
Description

Statements
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
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.

Sample Input
Input
1
2
3
Output
YES
Input
1
2
4
Output
YES
Input
1
3
5
Output
NO

啥话不要说,Java正面刚。。。
这里可能有同学不理解题意,我来说明一下是什么情况。比如1 2 4 ,我刚开始的时候没弄明白,后来意识到1+1=2也是可以的,题目没有问题

import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner cin = new Scanner(System.in);
        BigInteger a, b, c, t1, t2,t3, t4, t5, t6;
            a=cin.nextBigInteger(); 
            b=cin.nextBigInteger();
            c=cin.nextBigInteger();
            t1=a.add(a);
            t2=b.add(b);
            t3=c.add(c);
            t4=a.add(b);
            t5=a.add(c);
            t6=b.add(c);
            if(t1.equals(b)||t1.equals(c)||t2.equals(a)||t2.equals(c)||t3.equals(a)||t3.equals(b)||t4.equals(c)||t5.equals(b)||t6.equals(a))
                System.out.printf("YES");
            else
                System.out.printf("NO");
    }
}

你可能感兴趣的:(高精度)