Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
32055 | 陶俊宸 | 火柴棒等式 | C++ | Accepted | 100 | 8 MS | 252 KB | 527 | 2022-02-09 12:57:34 |
#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]){ 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*10,mn[i]+dm); } } } } int main(){ scanf("%hd",&n); ln=n; dfs(0,0,0); printf("%hd",ans); return 0; }