timu

· · 题解

AT_abc466_f [ABC466F] Many Mod Calculation

题目描述

You are given integers N,X and a length- N sequence of positive integers A=(A_1,A_2,\ldots,A_N) .

For a non-negative integer x , define f(x)=(\ldots((x \bmod A_1) \bmod A_2) \ldots ) \bmod A_N .

Find the number of integers x between 1 and X , inclusive, such that f(x)=0 .

You are given T test cases; solve each of them.

输入格式

The input is given from Standard Input in the following format:

T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T

Each test case is given in the following format:

N $ $ X $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N

输出格式

Output the answers for the test cases in order, separated by newlines.

输入输出样例 #1

输入 #1

4
3 7
5 2 3
9 31415
9 9 8 2 4 4 3 5 3
1 1000000000000000000
1
9 20260405
3141 5926 5358 9793 2384 6264 3383 2795 288

输出 #1

4
17452
1000000000000000000
77403

说明/提示

Sample Explanation 1

Consider the first test case.

For example, when x=7 , f(7)=(((7 \bmod 5) \bmod 2)\bmod 3)=(2\bmod 2)\bmod 3=0\bmod 3=0 .

There are four integers x between 1 and 7 such that f(x)=0 : x=2,4,5,7 .

Constraints