用线段树可以算出序列。然后o(1)询问。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar(); x = ;while(!isdigit(c)) c = getchar();
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
} const int maxn=;
int T,n,k,q,sz,cnt,p;
int s[*maxn],ans[maxn]; void build(int l,int r,int rt)
{
s[rt]=;
if(l==r){ s[rt]=; return;}
int m=(l+r)/;
build(l,m,*rt);
build(m+,r,*rt+);
s[rt]=s[*rt]+s[*rt+];
} void get(int sum,int l,int r,int rt)
{
if(l==r) { s[rt]=, p=l; return; }
int m=(l+r)/;
if(s[*rt]>=sum) get(sum,l,m,*rt);
else get(sum-s[*rt],m+,r,*rt+);
s[rt]=s[*rt]+s[*rt+];
} int main()
{
// File();
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&n,&k,&q);
build(,n,); sz=n; cnt=;
while(sz>)
{
int mx=(sz-)/k;
for(int i=;i<=mx;i++)
{
int sum=+i*k-i;
get(sum,,n,); ans[++cnt]=p; sz--;
}
}
for(int i=;i<=q;i++)
{
int x; scanf("%d",&x);
printf("%d\n",ans[x]);
}
}
return ;
}

HDU 5860 Death Sequence的更多相关文章

  1. HDU 5860 Death Sequence(死亡序列)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  2. HDU 5860 Death Sequence(递推)

    HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You ...

  3. hdu 5860 Death Sequence(递推+脑洞)

    Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historian liv ...

  4. 2016 Multi-University Training Contest 10 || hdu 5860 Death Sequence(递推+单线约瑟夫问题)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 题目大意:给你n个人排成一列编号,每次杀第一个人第i×k+1个人一直杀到没的杀.然后 ...

  5. 2016暑假多校联合---Death Sequence(递推、前向星)

    原题链接 Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historia ...

  6. HDU 1711 Number Sequence(数列)

    HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  7. HDU 1005 Number Sequence(数列)

    HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...

  8. HDU 1560 DNA sequence(DNA序列)

    HDU 1560 DNA sequence(DNA序列) Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K  ...

  9. HDU 1005 Number Sequence(数论)

    HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, ...

随机推荐

  1. canvas 弹幕效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 有关linux标准输出、标准输入、标准错误的重定向问题

    1.简单的命令行重定向问题. 例:ls  -al  test   test1  test2    1>out.txt  2>err.tx 这里ls这句命令行命令之后将标准输入重定向到out ...

  3. BAE部署Django项目流程整理

    1.首先在BAE上创建一个应用名称并付费2.把应用文件夹git到本地,此时文件夹会多出三个文件app.conf,favicon.ico,index.py3.在应用文件夹内创建本地项目:myblog,并 ...

  4. Form 提交表单

    ---HTML <form action="/Sample/SampleList/ExportSample" style="display:inline" ...

  5. python自动化开发-2

    1.python的数据类型之列表 列表是Python开发语言中最常见的数据类型之一,通过列表可以实现对数据的增删改等常用操作. 列表的定义:例子 names = ["Lucy",& ...

  6. react-gulp-browserify

    环境搭配参照 http://www.cnblogs.com/guolaomao/p/6276877.html 前半部分的内容. 首先安装browserify npm install --save-de ...

  7. deployd使用归纳

    deployd:一个生成后端数据的软件,简单的说就是大部分的前端不会后端,即使会也很难在深入到数据库进行设置一些前端所需数据的创建与查询的后端程序的书写,所以此时就是deployd大显身手的时候了. ...

  8. Oracle与Sqlserver:Order by NULL值介绍

    针对页面传参到in的子集中去进行查询操作的话,就会有in(xxx,null),这样就会导致查询的结果中其实直接过滤掉了null,根本就查不出来null的值.之前对于null的操作都是进行不同数据库的n ...

  9. jquery 获取当前对象的id取巧验证的一种方法

    <!doctype html><html><head><meta charset="utf-8"><title>titl ...

  10. HDU 4403 A very hard Aoshu problem

    暴力$dfs$. 先看数据范围,字符串最长只有$15$,也就是说枚举每个字符后面是否放置“$+$”号的复杂度为${2^{15}}$. 每次枚举到一种情况,看哪些位置能放“$=$”号,每个位置都试一下, ...