当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5213:Lucky

题目描述
WLD is always very lucky.His secret is a lucky number $K$.$k$ is a fixed odd number. Now he meets a stranger with $N$ numbers:$a1,a2,...,aN$.The stranger asks him $M$ questions.Each question is like this:Given two ranges $[Li,Ri]$ and $[Ui,Vi]$,you can choose two numbers $X$ and $Y$ to make $aX+aY=K$.The $X$ you can choose is between $Li$ and $Ri$ and the $Y$ you can choose is between $Ui$ and $Vi$.How many pairs of numbers$(X,Y)$ you can choose?
If WLD can answer all the questions correctly,he'll be the luckiest man in the world.Can you help him?
输入解释
There are multiple cases.(At MOST $5$)

For each case:

The first line contains an integer $N(1 \leq N \leq 30000)$.

The following line contains an integer $K(2 \leq K \leq 2*N)$,WLD's lucky number.K is odd.

The following line contains $N$ integers $a1,a2,...,aN(1 \leq ai \leq N)$.

The following line contains an integer $M(1 \leq M \leq 30000)$,the sum of the questions WLD has to answer.

The following $M$ lines,the i-th line contains $4$ numbers $Li,Ri,Ui,Vi(1 \leq Li \leq Ri < Ui \leq Vi \leq N)$,describing the i-th question the stranger asks.
输出解释
For each case:

Print the total of pairs WLD can choose for each question.
输入样例
5
3 
1 2 1 2 3
1 
1 2 3 5
输出样例
2

提示
a1+a4=a2+a3=3=K.
So we have two pairs of numbers (1,4) and (2,3).
Good luck!
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5213

最后修改于 2020-10-25T23:20:45+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)