303588: CF691F. Couple Cover
Memory Limit:512 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Couple Cover
题意翻译
给你 $n$ 个不同的球,第 $i$ 个球上有一个数字 $a_i$。 $m$ 次询问,每次给你一个 $p$,询问 $2$ 个人先后取球,有多少种不同的取球方案满足以下条件: + $a_i\times a_j\ge p$ 注意第 $1$ 个人取完球后不放回去。 两种方案不同当且仅当满足至少 $1$ 个人取到的球不同。 $1\le n,m\le 10^6,1\le p,a_i\le3\times10^6$题目描述
Couple Cover, a wildly popular luck-based game, is about to begin! Two players must work together to construct a rectangle. A bag with $ n $ balls, each with an integer written on it, is placed on the table. The first player reaches in and grabs a ball randomly (all balls have equal probability of being chosen) — the number written on this ball is the rectangle's width in meters. This ball is not returned to the bag, and the second player reaches into the bag and grabs another ball — the number written on this ball is the rectangle's height in meters. If the area of the rectangle is greater than or equal some threshold $ p $ square meters, the players win. Otherwise, they lose. The organizers of the game are trying to select an appropriate value for $ p $ so that the probability of a couple winning is not too high and not too low, but they are slow at counting, so they have hired you to answer some questions for them. You are given a list of the numbers written on the balls, the organizers would like to know how many winning pairs of balls exist for different values of $ p $ . Note that two pairs are different if either the first or the second ball is different between the two in pair, and two different balls with the same number are considered different.输入输出格式
输入格式
The input begins with a single positive integer $ n $ in its own line ( $ 1<=n<=10^{6} $ ). The second line contains $ n $ positive integers — the $ i $ -th number in this line is equal to $ a_{i} $ ( $ 1<=a_{i}<=3·10^{6} $ ), the number written on the $ i $ -th ball. The next line contains an integer $ m $ ( $ 1<=m<=10^{6} $ ), the number of questions you are being asked. Then, the following line contains $ m $ positive integers — the $ j $ -th number in this line is equal to the value of $ p $ ( $ 1<=p<=3·10^{6} $ ) in the $ j $ -th question you are being asked.
输出格式
For each question, print the number of winning pairs of balls that exist for the given value of $ p $ in the separate line.
输入输出样例
输入样例 #1
5
4 2 6 1 3
4
1 3 5 8
输出样例 #1
20
18
14
10
输入样例 #2
2
5 6
2
30 31
输出样例 #2
2
0