思路:插入的数按指数级增长,所以范围内最多存在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. [源码分析] 带你梳理 Flink SQL / Table API内部执行流程

    [源码分析] 带你梳理 Flink SQL / Table API内部执行流程 目录 [源码分析] 带你梳理 Flink SQL / Table API内部执行流程 0x00 摘要 0x01 Apac ...

  2. SpringMVC视图解析中的 forward: 与 redirect: 前缀

    在 SpringMVC 中,可以指定画面的跳转方式.使用 forward: 前缀实现请求转发跳转,使用 redirect: 前缀实现重定向跳转.有前缀的转发和重定向操作和配置的视图解析器没有关系,视图 ...

  3. java 多线--静态代理模式

    我们使用 java 多线程时,都需要通过线程代理对象来启动线程,常见的写法: new Thread(target).start(); 这在设计模式中叫静态代理模式,静态代理模式组成; 1.公共接口 2 ...

  4. SourceTree for Windows跳过登录解决方法

    来源:https://blog.csdn.net/t_332741160/article/details/79611303 SourceTree 是一个强大的git管理客户端,但是在使用最新版需要登录 ...

  5. javascript-网页尺寸

    scrollWidth:对象的实际内容的宽度,不包边线宽度,会随对象中内容超过可视区后而变大. clientWidth:对象内容的可视区的宽度,不包滚动条等边线,会随对象显示大小的变化而改变. off ...

  6. 使用宝塔面板部署tp5网站

    来源:https://www.cnblogs.com/e0yu/p/9102902.html 遇到一个问题,就是当thinkphp5部署在宝塔面板上,会出现这个问题: 参考解决办法: http://w ...

  7. 2019-2020-1 20199326《Linux内核原理与分析》第五周作业

    第五周学习内容 庖丁解牛Linux内核分析第四章:系统调用的三层机制(上) Linux内核分析实验四 学到的一些知识 4.1用户态.内核态.中断 宏观上Linux操作系统的体系架构分为用户态和内核态 ...

  8. hdu_1050 Moving Tables 贪心

    Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  9. 痞子衡嵌入式:揭秘i.MXRT1170 eFuse空间访问可靠性的保护策略(冗余与ECC)

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是恩智浦i.MXRT1170的eFuse空间访问可靠性保护策略. 关于i.MXRT系列的eFuse/OTP,痞子衡之前在介绍Boot时写过 ...

  10. 安装并使用pyecharts库

    在cmd命令行中输入安装命令, pyecharts库的安装命令如下: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyecharts ...