/* ID: mytbk921 LANG: C TASK: runround */ #include #include int runround(unsigned int x) { unsigned int msd, lsd, last, t; int next[10]; int map[10]; int i; for (i=0; i<10; i++) map[i] = 0; lsd = x % 10; if (lsd == 0) return 0; last = lsd; map[lsd] = 1; x /= 10; while (x>=10) { t = x % 10; if (map[t] || t==0) return 0; map[t] = 1; next[t] = last; last = t; x /= 10; } msd = x; map[msd] = 1; next[msd] = last; next[lsd] = msd; last = msd; do { if (map[last]) map[last] = 0; else return 0; t = last; for (i=0; i