#P8909. [RC-06] Multiples
[RC-06] Multiples
Problem Description
Given and an array of length , where are all positive integers, and each is generated uniformly at random in .
For each , compute how many positive integers in are multiples of exactly values among (that is, there exist exactly indices such that ).
Input Format
The first line contains two positive integers .
The next line contains positive integers .
Output Format
Output one line with integers. The -th integer is the answer for .
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: , , , and each is generated uniformly at random in .
In this problem, test cases satisfy , and test cases satisfy , for a total of 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 is generated uniformly at random in , so the sample is not valid input data. The testdata do not include the sample.
Translated by ChatGPT 5