time limit per test

0.25 s

memory limit per test

64 MB

input

standard input

output

standard output

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.

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

数据处理一下,用java简单,用c++麻烦点

c++:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define Max 105
using namespace std;
int flag = ;
char s[][Max],ans[][Max];
char s1[Max],s2[Max];
char *add(char *x,char *y)
{
if(strlen(x) < strlen(y))
{
strcpy(s1,y);
strcpy(s2,x);
}
else
{
strcpy(s1,x);
strcpy(s2,y);
}
int d = ,i = ;
for(i = ;i < strlen(s2);i ++)
{
d += s1[i] - '' + s2[i] - '';
s1[i] = d % + '';
d /= ;
}
while(s1[i])
{
d += s1[i] - '';
s1[i ++] = d % + '';
d /= ;
}
if(d)
{
s1[i ++] = d % + '';
d /= ;
s1[i] = '\0';
}
return s1;
}
void dfs(int k)
{
if(flag)return ;
if(k == )
{
if(strcmp(add(ans[],ans[]),ans[]) == )flag = ;
return ;
}
for(int i = ;i < ;i ++)
{
strcpy(ans[k],s[i]);
dfs(k + );
}
}
int main()
{
for(int i = ;i < ;i ++)
{
cin>>s[i];
reverse(s[i],s[i] + strlen(s[i]));
for(int j = strlen(s[i]);j >= ;j --)
{
if(s[i][j - ] != '')
{
s[i][j] = '\0';
break;
}
}
}
dfs();
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

java:

import java.util.Scanner;
import java.math.BigInteger;;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int flag = 0;
BigInteger d;
BigInteger a[] = new BigInteger[3];
for(int i = 0;i < 3;i ++)
a[i] = sc.nextBigInteger();
for(int i = 0;i < 3;i ++) {
if(flag == 1)break;
for(int j = 0;j < 3;j ++) {
if(flag == 1)break;
for(int k = 0;k < 3;k ++) {
if(flag == 1)break;
d = a[i];
if(a[i].add(a[j]).equals(a[k]))flag = 1;
a[i] = d;
}
}
}
if(flag == 1)System.out.println("YES");
else System.out.println("NO");
}
}

随机推荐

  1. GPL协议本身就是剥削,oracle维权玩的让人恶心

     我们先来看一下MySQL的版权问题.当前,MySQL采用双重授权(Dual Licensed),他们是GPL和MySQL AB制定的商业许可协议.如果你在一个遵循GPL的自由(开源)项目中使用MyS ...

  2. PHP-FPM 设置多pool、配置文件重写

    重写配置文件 1.清空php配置文件 命令:> /usr/local/php/etc/php-fpm.conf 2.重新写入php-fpm配置 命令:vim /usr/local/php/etc ...

  3. zabbix3.0安装(本文引用51cto博主烂泥行天下的文章,我也是参考他写的文章安装的zabbix)

    但是由于他文章写的时间有点久了,上面的关于安装zabbix之前需要安装的zabbix3.0yum源的链接失效了,所有我找了2个能用的zabbix 3.0yum源,其他的就不再写了 安装zabbix3. ...

  4. 安装MySQL 5.6

    记录安装mysql 5.6的全过程 下载安装包(尝试过使用mysql的yum源去安装--如果你的网络够好的话...) 注:我的系统是Centos 7.2的 如下,根据自己的需求去下载 CentOS L ...

  5. python数据可视化(持续更新)

    1.折线图 import numpy as np import matplotlib.pyplot as plt input_values = [1, 2, 3, 4, 5] s = [1, 4, 9 ...

  6. C语言细节注意

    前段时间用C语言写了个小的程序,也算是复习了下好久没有用的C语言.也是有好多的坑了,哈哈. 1.C语言的结构体 结构体的命名最好能够做到规范.因为不同的 编译环境下,不是很规范的命名有时候会导致莫名其 ...

  7. MYSQL的基本语句——思维导图

    如图 思维导图图片链接 http://www.edrawsoft.cn/viewer/public/s/a1718332616630 有道云笔记图片链接 http://note.youdao.com/ ...

  8. PAT1051. Pop Sequence (25)

    #include <iostream> #include <stack> using namespace std; int sizeMax,n,k; stack<int& ...

  9. on绑定阻止冒泡失败

    使用zepto库,有如下dom <div id="J_parent"> <a href="#"> <span>点我有惊喜&l ...

  10. strcpy的实现

    // // Strcpy.c // libin // // Created by 李宾 on 15/8/20. // Copyright (c) 2015年 李宾. All rights reserv ...