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. vs2012编译cocos2dx 3.10报错解决方法

    新建的一个cocos工程没有改过任何代码直接编译居然报错了? 百度了一下原来是因为vs2012不支持c++11的部分特性 cocos2dx 3.10正好就用到了vs2012不支持的那部分特性,所以报错 ...

  2. Java经纬读坐标的距离计算

    问题引出: 今天遇到经纬度坐标转换距离的工作,根据网站登录者的IP确定登录者目前的位置信息,将其经纬度信息与所有的营业厅的经纬度进行对比,网页上显示出距离登录者最近的营业厅地址,本打算就做一个二维坐标 ...

  3. oracle 11g的卸载

    oracle 11g 的卸载主要有两种方式:一种是使用Oracle Universal Installer管理工具,该工具以向导模式进行,比较简单.这里主要讲解第二种卸载数据库的方式-----使用”d ...

  4. 《网络对抗》 逆向及Bof进阶实践

    <网络对抗> 逆向及Bof进阶实践 实践目标 注入一个自己制作的shellcode并运行这段shellcode: 实践步骤 准备工作 root@5224:~# apt-get instal ...

  5. 20145219 《Java程序设计》第08周学习总结

    20145219 <Java程序设计>第08周学习总结 教材学习内容总结 通用API 日志API 1.java.util.logging包提供了日志功能相关类与接口,使用日志的起点是log ...

  6. 使用Kali Linux 破解无线网

    用到的工具 airmon-ngairodump-ngaireplay-ngaircrack-ng 过程 123456789101112131415161718192021222324 root@lm: ...

  7. TP多条件sql查询,分组排序

    $k=M('order a'); $bj=$k->join("left join __CHANGE__ b on b.tb_name='order'and a.order_id=b.t ...

  8. Spring中Value注解的使用

    Spring中Value注解的使用 分类: Spring2014-08-16 17:28 2985人阅读 评论(0) 收藏 举报 有的时候我们定义了Properties文件,并且使用Spring的Pr ...

  9. Java集合Collection&Map

    Map<K,V>是键值对,K - 此映射所维护的键的类型,V - 映射值的类型.键值是一一对应的关系: Collection是只有键,底层也是由键值对,但是值的类型被隐藏起来. Colle ...

  10. 4.微信小程序-B站:先把首页造出来

    (小安娜:失踪人口已上线,大家快来喷喷喷他!),sorry++,最近身边发生太多事情,导致这最关键的实战开篇都未写,(小安娜-分身1:懒就是懒,不负责任,我之前学的都忘了),(小安娜-分身2:上一篇双 ...