火柴棒等式

bcm12 肝就完了 2023-10-15 16:07:55 4
{{ vote && vote.total.up }}

共 2 条回复

yehongchen

#include

using namespace std;

int a[100000] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int f(int b) {

int s = 0;

while (b != 0) {

    s += a[b % 10];

    b /= 10;

}

return s;

}

int l = 0;

int main() {

freopen("B.in", "r", stdin);

freopen("B.out", "w", stdout);

int n;

cin >> n;

for (int i = 10; i <= 2000; i++) {
    a[i] = f(i);

}
for (int c = 0; c <= 1000; c++) {

    for (int u = 0; u <= 1000; u++) {
        if (a[c] + a[u] + a[c + u] == n - 4) {
            l++;
        }
    }
}

cout << l;

return 0;

}

bcm12 肝就完了

怎么做