博客
关于我
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/

你可能感兴趣的文章
PythonStudy
查看>>
Pythons__IMPORT__未按预期工作
查看>>
Pythont通过request以及BeautifulSoup爬取几千条情话
查看>>
pythonweb django的学习
查看>>
pythonweb网站开发基础django安装
查看>>
pythonweb网站开发基础创建django项目
查看>>
pythonweb网站开发基础添加应用
查看>>
Python_015 多线程
查看>>
python_73_pickle序列化(接72)
查看>>
python_code_418
查看>>
python_day10 协程 GEVENT
查看>>
python_day1作业
查看>>