提交时间:2022-01-29 09:25:37
运行 ID: 31144
#include<iostream> short n,ln,math[3],ans; const short mn[10]={6,2,5,5,4,5,6,3,7,6}; void dfs(short deep,short dn,short dm){ if(deep==3&&ln==4&&math[2]==math[0]+math[1]){ printf("%hd+%hd=%hd\n",math[0],math[1],math[2]); ans++; } if(deep==3||ln<=4) return; for(short i=0;i<10;i++){ if(ln-4>=mn[i]+dm){ math[deep]=i+dn*10; ln-=mn[i]+dm; dfs(deep+1,0,0); math[deep]=0; ln+=mn[i]+dm; if(i){ dfs(deep,i+dn,mn[i]+dm); } } } } int main(){ scanf("%hd",&n); ln=n; dfs(0,0,0); printf("%hd",ans); return 0; }