提交时间:2023-08-24 10:59:22
运行 ID: 99963
#include <iostream> using namespace std; int main() { int stick[10] = {6,2,5,5,4,5,6,3,7,6}; //下标代表数字,存储的数据代表拼出这个数字需要多少根火柴 int plus = 2,equa = 2; int p = 0; int s_num; cin >> s_num; for(int i = 0;i <= 1024;i++) { for(int k = 0;k <= 1024;k++) { int a = i,b = k; //拆分数字 int S = 0; if(a == 0) S += 6; while(a >= 1) { S += stick[a%10]; a /= 10; } //cout << i << ' ' << S << endl; if(S+4 >= s_num) continue; if(b == 0) S += 6; while(b >= 1) { S += stick[b%10]; b /= 10; } //cout << k << ' ' << S << endl; if(S+4 >= s_num) continue; int d = i+k; if(d == 0) S+= 6; //cout << "这是S" << S << endl; while(d >= 1) { S += stick[d%10]; d /= 10; } //cout << i+k << ' '<< S+4 << endl; if(S+4 == s_num) p++; } } cout << p; }