博客
关于我
Codeforces Round #615 (Div. 3) D. MEX maximizing(思维好题)
阅读量:400 次
发布时间:2019-03-05

本文共 835 字,大约阅读时间需要 2 分钟。

??????????????????????????????????????????????

???????t???????t%x??????????????????????????-x?????????????????????????????x?

?????

#include 
using 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/

你可能感兴趣的文章
Notes on Paul Irish's "Things I learned from the jQuery source" casts
查看>>
Notification 使用详解(很全
查看>>
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
查看>>
NotImplementedError: Could not run torchvision::nms
查看>>
nova基于ubs机制扩展scheduler-filter
查看>>
Now trying to drop the old temporary tablespace, the session hangs.
查看>>
nowcoder—Beauty of Trees
查看>>
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
np.power的使用
查看>>
NPM 2FA双重认证的设置方法
查看>>
npm build报错Cannot find module ‘html-webpack-plugin‘解决方法
查看>>
npm build报错Cannot find module ‘webpack/lib/rules/BasicEffectRulePlugin‘解决方法
查看>>
npm build报错Cannot find module ‘webpack‘解决方法
查看>>