本文共 862 字,大约阅读时间需要 2 分钟。
??????????????????????????????????????????????
???????t???????t%x??????????????????????????-x?????????????????????????????x?
?????
#includeusing namespace std;const int maxn = 4e5 + 10;int a[maxn];int main() { int q, x, t, ans = 0; scanf("%d %d", &q, &x); while (q--) { scanf("%d", &t); int pos = t % x; if (a[pos] == 0) { a[pos]++; } else { do { a[pos]--; pos = pos % x; } while (a[pos] == 0 && pos != 0); ans = pos; } if (a[ans] == 0) { ans = x; } do { a[ans]--; ans = ans % x; } while (a[ans] == 0 && ans != 0); printf("%d\n", ans); }}
??????????t?????x???pos???pos??????????????????????????????????????????????????x????????????????
转载地址:http://foewz.baihongyu.com/