问题 E: Sequence

内存限制:512 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:15 通过:5

题目描述

You have an array of nnn elements a1, a2,…, ana_1, \ a_2,\dots,\ a_na1, a2,, an.

For each task, you have three integers l,r,kl,r,kl,r,k.

Ask whether you can find an array bbb of k−1k-1k1 integers satisfy:

∙\bullet   l≤ b1< b2< b3<⋯< bk−1< r\ \ l \le \ b_1 < \ b_2 < \ b_3 < \dots < \ b_{k-1} < \ r  l b1< b2< b3<< bk1< r

∙\bullet  sum(l,\ sum(l, sum(l, b1), sum(b1+1,b_1) ,\ sum(b_1+1,b1), sum(b1+1, b2),…, sum(bk−1+1, r)b_2), \dots ,\ sum(b_{k-1}+1 ,\ r)b2),, sum(bk1+1, r) are the multiplies of 222

Specially, if k=1k=1k=1, it should satisfy sum(l,r)sum(l,r)sum(l,r) is the multiply of 222

We define sum(l,sum(l,sum(l, r)=∑i=lr air) = \sum_{i=l}^{r} \ a_ir)=i=lr ai (l≤r)(l\le r)(lr).

If possible, print "YES". Otherwise, print "NO

输入格式

Each test contains multiple test cases. The first line contains the number of test cases T(1≤T≤10000)T(1\le T\le 10000)T(1T10000).
The description of the test cases follows.
The first line contains two integers n, qn, \ qn, q(1≤n, q≤1051\le n ,\ q \le 10^51n, q105).
The second line contains nnn integers a1, a2,…, ana_1, \ a_2, \dots , \ a_na1, a2,, an(0≤ai≤10100 \le a_i \le 10^{10}0ai1010).
Each of the next qqq lines contains three integers l,r,kl, r, kl,r,k(1≤l≤ r≤ n,1≤ k≤1051\le l \le \ r \le \ n, 1 \le \ k \le 10^51l r n,1 k105).
It's guaranteed that ∑n, ∑q ≤ 5× 105\sum n, \ \sum q \ \le \ 5 \times \ 10^5n, ∑q  5× 105

输出格式

For each test case, output "YES" or "NO".

输入样例 复制

2
3 3
1 2 3
1 2 1
1 3 1
2 3 1
3 3
2 2 2
1 2 1
1 2 2
1 2 3

输出样例 复制

NO
YES
NO
YES
YES
NO