https://www.luogu.com.cn/problem/P1149
先把所有的数表示出来

#include <cstdio> #include <iostream> using namespace std; int b[1000] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}, n, cnt, i; int main() { cin >> n, n -= 4; for (i = 10; i <= 999; ++i) b[i] = b[i / 10] + b[i % 10]; for (i = 0; i <= 999; ++i) { for (int j = 0; j <= i; ++j) if (b[i] + b[j] + b[i - j] == n) cnt++; } cout << cnt; return 0; }