hdu2852 KiKi's K-Number】的更多相关文章

题目:http://www.spoj.com/problems/ORDERS/ and pid=2852">http://acm.hdu.edu.cn/showproblem.php? pid=2852 题意:spoj227:告诉每一个位置前面有多少个数比当前位置小,求出原序列. hdu2852:设计一个容器,支持几种操作:添加/删除元素,求容器中比a大的数中第k小的数是多少. 分析:两个题思路都是求数组里面的第K小的数.開始一直在找O(N*logN)的方法,后来发现O(N*logN*lo…
Problem Description For the k-th number, we all should be very familiar with it. Of course,to kiki it is also simple. Now Kiki meets a very similar problem, kiki wants to design a container, the container is to support the three operations. Push: Pus…
引入 权值树状数组就是数组下标是数值的数组,数组存储下标对应的值有几个数 题目 HDU-2852 KiKi's K-Number 题意 几种操作,p=0代表push:将数值为a的数压入盒子 p=1代表pop,代表删除数值为e的数,如果没有这个数,输出No Elment! p=2代表query,查询比第k个比a大的元素,找不到输出Not Find! Sample Input 5 0 5 1 2 0 6 2 3 2 2 8 1 7 0 2 0 2 0 4 2 1 1 2 1 2 2 1 3 2 1…
Problem Description For the k-th number, we all should be very familiar with it. Of course,to kiki it is also simple. Now Kiki meets a very similar problem, kiki wants to design a container, the container is to support the three operations. Push: Pus…
链接:https://ac.nowcoder.com/acm/contest/884/K来源:牛客网 题目描述 300iq loves numbers who are multiple of 300. One day he got a string consisted of numbers. He wants to know how many substrings in the string are multiples of 300 when considered as decimal inte…
博弈的一些概念: 必败点(P点) : 前一个选手(Previous player)将取胜的位置称为必败点. 必胜点(N点) : 下一个选手(Next player)将取胜的位置称为必胜点. 必败(必胜)点属性 (1) 全部终结点是必败点(P点): (2) 从不论什么必胜点(N点)操作,至少有一种方法能够进入必败点(P点): (3)不管怎样操作, 从必败点(P点)都仅仅能进入必胜点(N点). pid=2147">hdu 2147 kiki's game 题意: 在一个m*n的棋盘内,从(1,…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2852 题目大意: 题意:    给出三种操作,    0 在容器中插入一个数.    1 在容器中删除一个数.    2 求出容器中大于a的第k大元素. 解题思路: 用树状数组维护每个值,插入数字是add(x, 1),删除时add(x, -1) 查询第k大时,先判断是否存在,存在的话直接根据树状数组sum值的单调性二分法求解即可 #include<iostream> #include<cs…
题意:给定三个操作添加删除查询大于a的的第k大值----树状数组的逆向操作 给定a利用BIT查询有多少值比a小,这样比a大的k大值就应该有k+sum(a)个小于他的值 因此可以二分枚举k大值看看是不是满足条件.这里有一点需要注意,就是二分出答案时当前答案的的数量一定大于1因为这个wa了一次 详见代码: +;       }   {      ;i+=lowbit(i))      {          c[i]+=d;      }  }   {      ;      ;i-=lowbit(i…
>传送门< 题意:给你一个字符串s,求出其中能整除300的子串个数(子串要求是连续的,允许前面有0) 思路: >动态规划 记f[i][j]为右端点满足mod 300 = j的子串个数,可以容易的转移 则状态转移方程为:f[i][(10*j+num[i]) %300] = f[i][(10*j+num[i]) %300] + f[i-1][j] 解释:假如给你个数3,很容易得出3mod300的值就是3,f[3] = 1,然后在3后面加一位1,变为31,则31mod300的值为31,f[31…
https://ac.nowcoder.com/acm/contest/884/K 一开始整了好几个假算法,还好测了一下自己的样例过了. 考虑到300的倍数都是3的倍数+至少两个零(或者单独的0). 求以第i个位置的数为结尾的前缀和为j的数的方案数. 当遇到至少两个0的时候,ans+=dp[0][i-2]+1. +1是那两个0的贡献. 这样子算会漏算单独的0的贡献,最后加回去. 还因为忘记mod3段错误好几次. 老了. #include <bits/stdc++.h> using namesp…