P1149 [NOIP2008 提高组] 火柴棒等式

// Problem: P1149 [NOIP2008 提高组] 火柴棒等式
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1149
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// User: Pannnn

#include <bits/stdc++.h>

using namespace std;

int cntN(int i, int j, int k, vector<int> &info) {
    string str[] = { to_string(i), to_string(j), to_string(k) };
    
    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        for (char c : str[i]) {
            cnt += info[c - '0'];
        }
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    n -= 4;
    vector<int> info = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
            
    int res = 0;         
    for (int i = 0; i <= 999; ++i) {
        for (int j = 0; j <= 999; ++j) {
            int k = i + j;
            int cnt = cntN(i, j, k, info);
            if (cnt == n) {
                ++res;
            }
        }
    }
    cout << res << endl;
    return 0;
}
posted @ 2022-02-09 16:07  Pannnn  阅读(55)  评论(0)    收藏  举报
-->