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

你可能感兴趣的文章
platform_driver与file_operations两种方法开发led驱动
查看>>
PlatON共识方案详解:应用CBFT共识协议,提高共识效率
查看>>
QueryDict和模型表知识补充
查看>>
Querybase 使用与安装教程
查看>>
Playwright与Selenium的对比:谁是更适合你的自动化测试工具?
查看>>
quarz设置定时器任务的有效时间段_定时器?你知道有几种实现方式吗?
查看>>
PLC、DCS、SCADA的选型
查看>>
PLC中的电子凸轮的简单介绍
查看>>
PLC发展详解-ChatGPT4o作答+匹尔西
查看>>
PLC探针有什么用
查看>>
PLC接线详解
查看>>
PLC数组的使用(西门子)
查看>>
Quarzt定时调度任务
查看>>
SpringBoot之AOP详解
查看>>
PLC结构体(西门子)
查看>>
PLC编程语言ST文本语法的常用数据类型及变量
查看>>
PLC通讯方式
查看>>
Please install 'webpack-cli' in addition to webpack itself to use the CLI
查看>>
Ploly Dash,更新一个Dash应用程序JJJA上的实时人物
查看>>
Ploly烛台的定制颜色
查看>>