CF 75a
题意
给定两个数 a , b
令 c = a + b
试问 a , b , c 去掉数字 0 后为 a’ , b’ , c’
是否满足 a’ + b’ = = c’
分析
写一个函数,逐位去掉每个 0 即可
代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ch(int x)
{
int use = 0;
int re = 0;
while(x)
{
if(x % 10 != 0)
{
use = (use << 3) + (use << 1) + x % 10;
}
x /= 10;
}
while(use)
{
re = (re << 3) + (re << 1) + use % 10;
use /= 10;
}
return re;
}
signed main()
{
int a , b;
scanf("%lld %lld" , &a , &b);
printf("%s" , (ch(a) + ch(b) == ch(a + b) ? "YES" : "NO"));
return 0;
}