Given an array of positive numbers, the task is to find the number of possible contiguous subarrays having product less than a given number K.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains two integers N & K and the second line contains N space separated array elements.

**Output:**

For each test case, print the count of required subarrays in new line.

**Constraints:**

1<=T<=200

1<=N<=10^{5}

1<=K<=10^{15}

1<=A[i]<=10^{5}

**Example:
Input:**

2

4 10

1 2 3 4

7 100

1 9 2 8 6 4 3

**Output:**

7

16

**Explanation:**

Input : A[]={1, 2,3,4} K = 10 Output : 7 The contiguous subarrays are {1}, {2}, {3}, {4} {1, 2}, {1, 2, 3} and {2, 3} whose count is 7.

Author: arun03

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Akkki111 | 38 |

SaltBaeSama | 34 |

ambercyrus | 33 |

LegendFire | 32 |

chocozz | 32 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1219 |

mazumderrohit8 | 1095 |

SumitSingh27 | 1090 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4566 |

Quandray | 4444 |

Login to report an issue on this page.