思路:插入的数按指数级增长,所以范围内最多存在logR个数。并且最近i次插入的数,首位置为2^(i-1),且每隔2^i出现一次,于是暴力之。。可以用插入排序维护,也可查询时再排下序。

一:

 #pragma comment(linker, "/STACK:10240000,10240000")

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <ctime>
#include <cctype>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <stdexcept>
#include <utility> using namespace std; #define mem0(a) memset(a, 0, sizeof(a))
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define define_m int m = (l + r) >> 1
#define rep0(a, b) for (int a = 0; a < (b); a++)
#define rep1(a, b) for (int a = 1; a <= (b); a++)
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x) & (-(x)))
#define constructInt4(name, a, b, c, d) name(int a = 0, int b = 0, int c = 0, int d = 0): a(a), b(b), c(c), d(d) {}
#define constructInt3(name, a, b, c) name(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
#define constructInt2(name, a, b) name(int a = 0, int b = 0): a(a), b(b) {}
#define pchr(a) putchar(a)
#define pstr(a) printf("%s", a)
#define sint(a) ReadInt(a)
#define sint2(a, b) ReadInt(a);ReadInt(b)
#define sint3(a, b, c) ReadInt(a);ReadInt(b);ReadInt(c)
#define pint(a) WriteInt(a) typedef double db;
typedef long long LL;
typedef pair<int, int> pii;
typedef multiset<int> msi;
typedef set<int> si;
typedef vector<int> vi;
typedef map<int, int> mii; const int dx[] = {, , , -, , , -, -};
const int dy[] = {, , -, , -, , , -};
const int maxn = 1e3 + ;
const int maxm = 1e5 + ;
const int maxv = 1e7 + ;
const int max_val = 1e6 + ;
const int MD = 1e9 +;
const int INF = 1e9 + ;
const double PI = acos(-1.0);
const double eps = 1e-; template<class T>T gcd(T a, T b){return b==?a:gcd(b,a%b);}
template<class T>void ReadInt(T &x){char c=getchar();while(!isdigit(c))c=getchar();x=;while(isdigit(c)){x=x*+c-'';c=getchar();}}
template<class T>void WriteInt(T i) {int p=;static int b[];if(i == ) b[p++] = ;else while(i){b[p++]=i%;i/=;}for(int j=p-;j>=;j--)pchr(''+b[j]);} struct abc {
pii a[];
int l, r;
void Init() { l = r = ; }
void push_back(int x) {
a[r++] = make_pair(x, );
for(int i = l; i < r - ; i++) a[i].second++;
if (r - l >= ) {
int pos;
for (int i = l; i < r; i++) {
if (a[i].second == ) {
pos = i;
break;
}
}
for (int i = pos; i > l; i--) a[i] = a[i - ];
l++;
}
int p = r - ;
while (p > l && a[p].first < a[p - ].first) {
swap(a[p], a[p - ]);
p--;
}
}
pii &operator [] (int i) {
return a[l + i];
}
int size() {
return r - l;
}
}; abc g; LL calc(LL x, LL pos) {
if (x < pos) return ;
return (x - pos) / pos / + ;
}
int main() {
//freopen("in.txt", "r", stdin);
int n;
while (cin >> n) {
g.Init();
rep0(i, n) {
int id, w;
sint(id);
if (id == ) {
sint(w);
g.push_back(w);
}
else {
LL L, R, k;
sint3(L, R, k);
int sz = g.size();
rep0(i, sz) {
LL pos = 1LL << g[i].second, c = calc(R, pos) - calc(L - , pos);
if (k <= c) {
pint(g[i].first);
pchr('\n');
break;
}
k -= c;
}
}
}
}
return ;
}

二:

 #pragma comment(linker, "/STACK:10240000,10240000")

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <ctime>
#include <cctype>
#include <set> using namespace std; #define mem0(a) memset(a, 0, sizeof(a))
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define define_m int m = (l + r) >> 1
#define rep0(a, b) for (int a = 0; a < (b); a++)
#define rep1(a, b) for (int a = 1; a <= (b); a++)
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x) & (-(x)))
#define constructInt4(name, a, b, c, d) name(int a = 0, int b = 0, int c = 0, int d = 0): a(a), b(b), c(c), d(d) {}
#define constructInt3(name, a, b, c) name(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c) {}
#define constructInt2(name, a, b) name(int a = 0, int b = 0): a(a), b(b) {}
#define pchr(a) putchar(a)
#define pstr(a) printf("%s", a)
#define sint(a) ReadInt(a)
#define sint2(a, b) ReadInt(a);ReadInt(b)
#define sint3(a, b, c) ReadInt(a);ReadInt(b);ReadInt(c)
#define pint(a) WriteInt(a) typedef double db;
typedef long long LL;
typedef pair<int, int> pii;
typedef multiset<int> msi;
typedef set<int> si;
typedef vector<int> vi;
typedef map<int, int> mii; const int dx[] = {, , , -, , , -, -};
const int dy[] = {, , -, , -, , , -};
const int maxn = 1e3 + ;
const int maxm = 1e5 + ;
const int maxv = 1e7 + ;
const int max_val = 1e6 + ;
const int MD = 1e9 +;
const int INF = 1e9 + ;
const double PI = acos(-1.0);
const double eps = 1e-; template<class T>T gcd(T a, T b){return b==?a:gcd(b,a%b);}
template<class T>void ReadInt(T &x){char c=getchar();while(!isdigit(c))c=getchar();x=;while(isdigit(c)){x=x*+c-'';c=getchar();}}
template<class T>void WriteInt(T i) {int p=;static int b[];if(i == ) b[p++] = ;else while(i){b[p++]=i%;i/=;}for(int j=p-;j>=;j--)pchr(''+b[j]);} struct abc {
int a[];
int l, r;
void Init() { l = r = ; }
void push_back(int x) {
a[r++] = x;
if (r - l >= ) {
l++;
}
}
int &operator [] (int i) {
return a[l + i];
}
int size() {
return r - l;
}
}; abc g; pair<int, LL> a[]; LL calc(LL x, int id) {
LL start = 1LL << (g.size() - id - ), t = 1LL << (g.size() - id);
if (x < start) return ;
return (x - start) / t + ;
} int main() {
//freopen("in.txt", "r", stdin);
int n;
while (cin >> n) {
g.Init();
rep0(i, n) {
int id, w;
sint(id);
if (id == ) {
sint(w);
g.push_back(w);
}
else {
LL L, R, k;
sint3(L, R, k);
int total = , sz = g.size();
rep0(i, sz) {
LL c = calc(R, i) - calc(L - , i);
if (c > ) a[total++] = make_pair(g[i], c);
}
sort(a, a + total);
int now = ;
while () {
if (k <= a[now].second) {
break;
}
k -= a[now++].second;
}
pint(a[now].first);
pchr('\n');
}
}
}
return ;
}

[hdu5204]水题的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  4. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  5. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  6. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

随机推荐

  1. react-devtools安装调试

    初学react,Chrome F12调试,需要一款插件react-devtools. 网上大多对于翻墙不利索的同学大多才用了git源码.npm本地手动打包Chrome拓展程序.如:https://ww ...

  2. python之excel表操作

    python对excel表操作主要用到三个库,xlrd,xlwt,xlutils,分别用于excel表读,写,修改操作,以下将一个简单介绍 一.生成excel表:xlwt类 新建excel表,并写入数 ...

  3. python 工具链 包管理工具 pip

    Installation mac下可以采用 brew,easy_install(python自带)等方式安装. centos下可以采用yum,easy_install等方式安装. 但是上面两种方式在系 ...

  4. .NET Core下的开源分布式任务调度系统ScheduleMaster-v2.0低调发布

    从1月份首次公开介绍这个项目到现在也快4个月了,期间做了一些修修补补整体没什么大的改动.2.0算是发布之后第一个大的版本更新,带来了许多新功能新特性,也修复了一些已知的bug,在此感谢在博客.Issu ...

  5. [WPF] 考古Expression Web:微软当年最漂亮的WPF软件

    1. 什么是Expression Web Expression Studio是微软在2007年推出的一套针对设计师的套件,其中包含专业的设计工具和新技术,可以弹性且自由地将设计方案转为实际--无论设计 ...

  6. 痞子衡嵌入式:大话双核i.MXRT1170之Cortex-M7与Cortex-M4互相激活之道

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家分享的是恩智浦i.MXRT1170上Cortex-M7与Cortex-M4内核互相激活的方法. 痞子衡最近在深耕i.MXRT1170这颗划时代的 ...

  7. 新建MapReduce项目

    添加各种jar包 /usr/local/hadoop/share/hadoop/.. 这几个文件夹下的jar包以及它们子目录lib下的所有jar包 将/usr/local/hadoop/etc/had ...

  8. 初学者的Pygame安装教程

    最近在自学python,在看完了些基础知识之后,准备写个小项目[外星人入侵],这个项目需要安装pygame. 所以就在网上找到了两个下载地址https://bitbucket.org/pygame/p ...

  9. tagbar 调到函数定义再跳回

    首先要在源码文件夹下执行 ctags -R * 生成tags文件 齐次要安装 YouCompleteMe ctrl + ] 跳到函数定义 Ctrl-o 和 Ctrl-I 跳回.我试验的只有 Ctrl- ...

  10. vue项目中使用bpmn-基础篇

    内容概述 本系列“vue项目中使用bpmn-xxxx”分为五篇,均为自己使用过程中用到的实例,手工原创,目前属于陆续更新中.主要包括vue项目中bpmn使用实例.应用技巧.基本知识点总结和需要注意事项 ...