用线段树可以算出序列。然后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. HTML5之Audio音频标签学习

    HTML5中的新元素标签 src:音频文件路径. autobuffer:设置是否在页面加载时自动缓冲音频. autoplay:设置音频是否自动播放. loop:设置音频是否要循环播放. control ...

  2. 办理阿尔伯塔大学(本科)学历认证『微信171922772』Alberta学位证成绩单使馆认证University of Alberta

    办理阿尔伯塔大学(本科)学历认证『微信171922772』Alberta学位证成绩单使馆认证University of Alberta Q.微信:171922772办理教育部国外学历学位认证海外大学毕 ...

  3. java转发和重定向

    1,请求重定向:客户端行为,response.sendRedirect(),从本质上讲等同于两次请求,前一次的请求对象不会保持,地址栏的URL地址会改变.2,请求转发:服务器行为,request.ge ...

  4. ACM第三题 完美立方

    形如a3= b3 + c3 + d3的等式被称为完美立方等式.例如123= 63 + 83 + 103 .编写一个程序,对任给的正整数N (N≤100),寻找所有的四元组(a, b, c, d),使得 ...

  5. CodeForces 635C XOR Equation

    位运算. 又涨姿势了:$a + b = (aXORb) + 2*(aANDb)$,$ (aXORb)$是不进位的部分,$2*(aANDb)$为进位之后的部分,相加就是$a + b$. 知道了这个转换, ...

  6. tab切换☆☆☆☆☆

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  7. 移动APP脚本录制

    1.安装补丁--LR_03105_patch4----mobile app(http/html) 2.录制软件和移动设备同处同一环境(160wifi连接移动设备),创建wifi热点 3.创建脚本-协议 ...

  8. JS判断在哪个浏览器打开

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  9. <video>和<audio>标签,对视频和音频的支持

    H5新增了<video>和<audio>标签,提供对视频和音频的支持 <audio>的属性与<video>属性相同 <video> vide ...

  10. android下拉刷新控件 android-pulltorefresh

    运行效果: 介绍:ListView.ViewPager.WevView.ExpandableListView.GridView.(Horizontal)ScrollView.Fragment上下左右拉 ...