// @BEGIN_OF_SOURCE_CODE /* @JUDGE_ID: 17243NT 139 C++ "It worked, but I don't understand it." */ // Send to judge@uva.es #include #include #include #ifdef ONLINE_JUDGE #define ins cin #define outs cout #else #define ins fin #define outs fout ifstream fin("myprog.in"); ofstream fout("myprog.out"); #endif typedef struct { char code[10]; char name[30]; double price; } locality; locality areas[10000]; int narea; int main() { int len, min, i, j; char telly[20]; char c; while(ins >> telly) { if(strcmp(telly, "000000") == 0) break; strcpy(areas[narea].code, telly); ins >> c; ins.putback(c); len = 0; for(;;) { ins.get(areas[narea].name[len]); if(areas[narea].name[len] == '$') break; len++; } areas[narea].name[len++] = '\0'; ins >> areas[narea].price; narea++; } outs.setf(ios::fixed); outs.precision(2); while(ins >> telly) { if(telly[0] == '#') break; ins >> min; if(telly[0] != '0') { outs << telly << " Local " << telly << " " << min << " 0.00 0.00\n"; } else { for(i = 0; i < narea; i++) { int tlen = strlen(telly); len = strlen(areas[i].code); for(j = 0; j < len; j++) if(areas[i].code[j] != telly[j]) break; if(j == len && tlen <= 15) { if(telly[1] == '0') { if(tlen - len >= 4 && tlen - len <= 10) break; } else { if(tlen - len >= 4 && tlen - len <= 7) break; } } } if(i == narea) { outs << telly << " Unknown " << min << " " << -1. << endl; } else { outs << telly << " " << areas[i].name << " " << &telly[len] << " " << min << " " << areas[i].price * .01 << " " << areas[i].price * min * .01 << endl; } } } return 0; } // @END_OF_SOURCE_CODE