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

你可能感兴趣的文章
pycharm可视化数据库
查看>>
pytorch 中的 #@save的意思
查看>>
Pycharm如何取消自动换行
查看>>
PyCharm安装及使用说明
查看>>
pycharm导入自己写的模块时,模块下方出现红色波浪线的解决方案
查看>>
Pycharm常用快捷键大全
查看>>
PyCharm快捷键
查看>>
Pycharm快捷键记录
查看>>
pycharm怎么支持WPS?
查看>>
pycharm打印不全问题
查看>>
pycharm提示This inspection detects instance attribute definition outside __init__ method
查看>>
pycharm搭建spark环境
查看>>
pycharm无法导入本地模块问题
查看>>
PyTorch — 初学者教程
查看>>
PyCharm更换pip源为国内源、模块安装、PyCharm依赖包导入导出教程
查看>>
Pycharm没有找到manage repositories按钮解决方案
查看>>
PyCharm点击设置没反应,无法进行设置
查看>>
pycharm的安装配置和简单使用
查看>>
pycharm的环境管理-ChatGPT4o作答
查看>>
pycharm社区版不能使用conda
查看>>