解題心得
暴力解
程式碼
#include <iostream> using namespace std; int main() { string c="0111001111", d="0111001110", e="0111001100", f="0111001000", g="0111000000", a="0110000000", b="0100000000", C="0010000000", D="1111001110", E="1111001100", F="1111001000", G="1111000000", A="1110000000", B="1100000000"; int t; cin>>t; while(t--) { string s, now="0000000000", next; int count[10]={0}; cin>>s; for(int i=0;i<s.size();i++) { if(s[i]=='c') next=c; else if(s[i]=='d') next=d; else if(s[i]=='e') next=e; else if(s[i]=='f') next=f; else if(s[i]=='g') next=g; else if(s[i]=='a') next=a; else if(s[i]=='b') next=b; else if(s[i]=='C') next=C; else if(s[i]=='D') next=D; else if(s[i]=='E') next=E; else if(s[i]=='F') next=F; else if(s[i]=='G') next=G; else if(s[i]=='A') next=A; else if(s[i]=='B') next=B; for(int i=0;i<10;i++) { if(now[i]=='0'&&next[i]=='1') count[i]++; } now=next; } for(int i=0;i<10;i++) { if(i!=9) cout<<count[i]<<" "; else cout<<count[i]<<endl; } } return 0; }