| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 91655 | sh25_shenpy | 火柴棒等式 | C++ | 解答错误 | 15 MS | 252 KB | 940 | 2026-06-14 14:14:37 |
#include <iostream> using namespace std; // 0~9 每个数字对应的火柴数 int num[] = {6,2,5,5,4,5,6,3,7,6}; // 计算数字 x 需要的火柴总数 int countMatch(int x) { if (x == 0) return 6; int res = 0; while (x > 0) { res += num[x % 10]; x /= 10; } return res; } int main() { int n; cin >> n; int total = 0; // 符号固定占用 4 根 int left = n - 4; if (left < 6) // A,B,C 至少各2根,合计最少6根 { cout << 0 << endl; return 0; } // 枚举 A,B for (int A = 1; A <= 1000; A++) { for (int B = 1; B <= 1000; B++) { int C = A + B; int sum = countMatch(A) + countMatch(B) + countMatch(C); if (sum == left) { total++; } } } cout << total << endl; return 0; }