#include #include void insert(long long *box, long long val, int i) { int loc = (val + i * i) % 10; if (loc < 10 && box[loc] == 0) { box[loc] = val; } else { insert(box, val, i + 1); } } int main(void) { long long box[10] = {}; long long phone; while (scanf("%lld,", &phone) != EOF) { insert(box, phone, 0); } for (int i = 0, size = 10; i < size - 1; i++) { printf("%lld,", box[i]); } printf("%lld", box[9]); return 0; }