#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; int main() { int N, Q, L, R, K; scanf("%d %d", &N, &Q); int A[N]; for (int i = 0; i < N; i++) scanf("%d", &A[i]); while (Q--) { scanf("%d %d %d", &L, &R, &K); int cnt = 0; for (int i = L - 1; i < R; i++) { if (A[i] % K == 0) cnt++; } printf("%d\n", cnt); } }