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

你可能感兴趣的文章
Python-模块与包的管理
查看>>
PYTHON-模块定义 搜索路径
查看>>
Python-爬虫工程师-面试总结
查看>>
Python-类与文件读取结合
查看>>
python-类思想-实现简单增删查改
查看>>
python-网络编程
查看>>
python写入文件出现空行
查看>>
PYTHON-返回给定x的多边形路径的y坐标
查看>>
python-进程池与线程池,协程
查看>>
Python-通过函数传递变量
查看>>
Python内置函数详解——总结篇
查看>>
Python.对象集合中的标识.和散列
查看>>
Python.硒.拖放错误“AttributeError:move_to 需要 WebElement“
查看>>
Python内置函数详解
查看>>
Python/Kivy:从一个类调用函数到另一个类并在 Python 中显示小部件
查看>>
Python/Kivy:我可以在双击标签时调用函数吗
查看>>
python内置函数5-frozenset()
查看>>
Python/Plotly:如何使用要显示的信息自定义悬停模板?
查看>>
Python/Selenium - 无法单击 www.instagram.com 上的“接受 cookie“按钮
查看>>
Python内置函数(35)——next
查看>>