#P8909. [RC-06] Multiples

[RC-06] Multiples

Problem Description

Given nn and an array aa of length nn, where a1ana_1 \sim a_n are all positive integers, and each aia_i is generated uniformly at random in [1,109][1,10^9].

For each 0kn0 \le k \le n, compute how many positive integers xx in [1,m][1,m] are multiples of exactly kk values among aia_i (that is, there exist exactly kk indices 1in1 \le i \le n such that aixa_i \mid x).

Input Format

The first line contains two positive integers n,mn, m.

The next line contains nn positive integers a1ana_1 \sim a_n.

Output Format

Output one line with n+1n+1 integers. The ii-th integer is the answer for k=i1k=i-1.

5 1000000
1 2 3 4 5
0 266666 333335 266665 116668 16666

Hint

There are no partial scores in this problem. You only get points if you get AC.

All testdata satisfy: 1n25001 \le n \le 2500, 1m1091 \le m \le 10^9, 1ai1091 \le a_i \le 10^9, and each aia_i is generated uniformly at random in [1,109][1,10^9].

In this problem, 66 test cases satisfy n=2500n=2500, and 22 test cases satisfy n10n \le 10, for a total of 88 test cases.

All testdata are generated in the following way: run the following pseudocode exactly once, and use its output as your input.

function rnd(int l,int r):

return a random integer in [l,r]

function main():

input n,m for this test case
output n,m
output n positive integers, each is the return value of rnd(1,10^9)

If you do not understand the generation method above, you can also read the corresponding C++ code:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	freopen("in.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	cout<<n<<' '<<m<<'\n';
	mt19937_64 rng(time(0));
	const int M=1e9;
	for(int i=1;i<=n;i++)cout<<rng()%M+1<<' ';
}

The sample does not satisfy that aia_i is generated uniformly at random in [1,109][1,10^9], so the sample is not valid input data. The testdata do not include the sample.

Translated by ChatGPT 5