Skip to content
Author: loop3r
Date: 20260224
tag: 枚举
link: https://www.luogu.com.cn/problem/P1149

问题描述

link

分析

参考代码

cpp
#include <bits/stdc++.h>
using namespace std;

int n;
int t[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int f(int n) {
    if (!n) return t[0];

    int ans = 0;
    while (n) {
        ans += t[n % 10];
        n /= 10;
    }

    return ans;
}

int main() {
    cin >> n;

    int ans = 0;
    for (int i = 0; i < 1000; i++) {
        for (int j = 0; j < 1000; j++) {
            // 4 + =
            if (f(i) + f(j) + f(i + j) + 4 == n) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}