↓あとで
int main() { int test_cases; cin>>test_cases; REP(ttt, test_cases) { int A, B; cin>>A>>B; int sp=1; VI tb; VI tb2; while(B>sp*10) { sp*=10; tb.PB(sp); } REP(i, tb.size()) tb2.PB(sp*10/tb[i]); int ans=0; for(int i=A;i<=B;i++) { //cout<<"i "<<i<<endl; set<int> used; REP(j, tb.size()) { int b = i/tb[j] + (i%tb[j])*tb2[j]; if(i<b && A<=b && b<=B && /* ADDED */ used.insert(b).second) { ans++; //cout<<b<<endl; } } } cout<<"Case #"<<ttt+1<<": "<<ans<<endl; } return 0; }