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

你可能感兴趣的文章
NYOJ 1066 CO-PRIME(数论)
查看>>
NYOJ 737:石子合并(一)(区间dp)
查看>>
nyoj 91 阶乘之和(贪心)
查看>>
nyoj------203三国志
查看>>
NYOJ-525 一道水题
查看>>
NYOJ127星际之门(一)
查看>>
nyoj58 最少步数
查看>>
N皇后问题
查看>>
N皇后问题
查看>>
n种方式教你用python读写excel等数据文件
查看>>
OAuth 2.0 MAC Tokens
查看>>
OAuth 及 移动端鉴权调研
查看>>
OAuth2 + Gateway统一认证一步步实现(公司项目能直接使用),密码模式&授权码模式
查看>>
OAuth2 Provider 项目常见问题解决方案
查看>>
OAuth2 vs JWT,到底怎么选?
查看>>
Vue.js 学习总结(14)—— Vue3 为什么推荐使用 ref 而不是 reactive
查看>>
oauth2-shiro 添加 redis 实现版本
查看>>
OAuth2.0_JWT令牌-生成令牌和校验令牌_Spring Security OAuth2.0认证授权---springcloud工作笔记148
查看>>
OAuth2.0_JWT令牌介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记147
查看>>