题解:P15086 [UOI 2025 II Stage] A+B=C
cjn1122334 · · 题解
不难发现,因为要经过若干次的移动,我们可以将原来的
代码
#include<bits/stdc++.h>
#define int long long
#define N 1919810ll
#define Mod 998244353ll
#define pii pair<int,int>
#define qck ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int arr[11]={6,2,5,5,4,5,6,3,7,6};//每个数字用多少
int a,b,c;
signed main(){
qck;
cin>>a>>b>>c;
int sum=arr[a]+arr[b]+arr[c];//预处理
for(int j=0;j<=c;j++){//枚举第一个加数
int l=c-j;//另一个加数=和-加数
int cnt=arr[c]+arr[j]+arr[l];
if(cnt==sum){//相等
cout<<"Yes\n";
return 0;
}
}
cout<<"No\n";//没有匹配上,输出无解
return 0;
}