通俗易懂解答(
2025-01-23 23:46:03
发布于:江西
7阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
#define re register
#define vv vector
#define int long long
#define P pair<int,int>
const int MOD = 100003;
const int N = 1e4 + 5;
int n, res;
int t[10000] = { 6,2,5,5,4,5,6,3,7,6 };//需要火柴棒的数量
void solve()
{
cin >> n;
n -= 4;//'+'和'='
for (int i = 10; i < 10000; i++) {
t[i] = t[i / 10] + t[i % 10];//递推式,比如102=10+2,10和2我们之前算过
}
for (int i = 0; i < 5000; i++) {
for (int j = 0; j < 5000; j++) {
if (t[i] + t[j] + t[i + j] == n ) //保证i+j不越界
res++;
}
}
cout << res;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
这里空空如也
有帮助,赞一个