题解:P15086 [UOI 2025 II Stage] A+B=C
水橙。暴枚就可以。
题面简述
给定火柴摆出的
思路
题目中给定
- 判断等式是否原来就成立。
- 如果不成立,把每一个数字所需的火柴数存在数组里,枚举小于
c 的全部情况,判断是否可行。 - 如果都不可行,输出
No。AC code
::::success[代码]
#include<bits/stdc++.h> using namespace std; int r[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; // 存储所需火柴数量 int main(){ int a, b, c; cin >> a >> b >> c; if(a + b == c){ cout << "Yes"; // 判断灯饰是否成立 return 0; } int target = r[a] + r[b]; // 目标 for(int i = 0; i <= c / 2; i++){ if(r[i] + r[c - i] == target){ cout << "Yes"; return 0; // 可以了直接退出程序 } } cout << "No"; return 0; } /* directed by Bright_algorithmer01 this is a solution */:::: AC 记录
切题千万条,学术第一条。作弊抄题解,棕名两行泪!