Yet another A + B
一、原文
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
二、分析(收获)
1)本题为大数据加法,建议字符数组,利用strcmp好比较。当然结构体和string也是可以的。
2)利用DFS来巧妙处理组合问题。
3)细节上:1、对大数逆置,低位在前利于后续加法和比较
2、通过预处理(比较大小、处理前置0)和*char来传递数组
3、对于最高仍然有进位需要单独处理
三、代码
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define Max 105
using namespace std;
int flag = 0;
char s[3][Max],ans[3][Max];
char s1[Max],s2[Max];
char *add(char *x,char *y)
{
if(