早教吧作业答案频道 -->其他-->
Giveyouanumbersequence,canyoutellmebetweenthei-thnumberandthej-thnumber,whichisthemaximumandwhichistheminimum?InputThefirstlineoftheinputisNandQ.N(N<2^17)isthenumberofintegersandQ(Q<2^17)isthenumberofqu
题目详情
Give you a number sequence,can you tell me between the i-th number and the j-th number,which is the maximum and which is the minimum?
Input
The first line of the input is N and Q.N(N< 2^17) is the number of integers and Q(Q < 2^17) is the number of querys.The second line is the N integers and the following Q lines include two integers i and j(i
Input
The first line of the input is N and Q.N(N< 2^17) is the number of integers and Q(Q < 2^17) is the number of querys.The second line is the N integers and the following Q lines include two integers i and j(i
▼优质解答
答案和解析
区间最值RMQ
ST算法或者线段树
提供一个ST代码
/*
Range Minimum Query
Sparse Table (ST) algorithm
*/
#include
#include
#define min(x,y) (x)(y)?(x):(y)
#define N 100005
int n,s[N],dp[N][25],MAX[N][25],MIN[N][25];
void slove()//psotion
{
int i,j;
for(i=0;i
ST算法或者线段树
提供一个ST代码
/*
Range Minimum Query
Sparse Table (ST) algorithm
*/
#include
#include
#define min(x,y) (x)(y)?(x):(y)
#define N 100005
int n,s[N],dp[N][25],MAX[N][25],MIN[N][25];
void slove()//psotion
{
int i,j;
for(i=0;i
看了 Giveyouanumber...的网友还看了以下:
Giveyouanumbersequence,canyoutellmebetweenthei-th 2020-04-27 …
等比数列前N项和的问题等比数列前N项和公式a(1-q^n)/1-q里1-q^n如果这里的n次方是偶 2020-05-13 …
线性代数定理求证明Q为n*n维方阵由(n-q)*n微矩阵D 和q*n维矩阵C构成则C左乘Q逆将图示 2020-05-16 …
等比数列an=a1*q^(n-1),Sn=a1(1-q^n)/(1-q)∴a3=2=a1*q^(3 2020-05-17 …
在等比数列an中,若a2=6,且a5-2a4-a3+12=0,则an为答题中a5-2a4-a3+1 2020-06-14 …
等比数列an=a1*q^(n-1),Sn=a1(1-q^n)/(1-q)∴a3=2=a1*q^(3 2020-06-17 …
为什么要用这个减法S(n)-q*S(n)?是为了求什么因为x^n这是一个等比数列,首项为x,公比也 2020-07-11 …
我们把分数分子是1,分母是正整数的分数叫做分数单位.任何一个单位分数1/n=1/p+1/q(n,p 2020-07-30 …
请问:无穷等比数列{an}的前n项和是S=a1/(1-q)还是Sn=a1(1-q^n)/(1-q) 2020-08-02 …
二项式定理题急已知an=1+q+q^2+……+q^(n-1)(n属于正整数,q不等于正负1),An= 2021-01-14 …