CF691F.Couple Cover
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
情侣封盖(Couple Cover)是一款广受欢迎的、基于运气的游戏,即将开始!两名玩家必须合作构造一个矩形。桌上放置了一个装有 n 个球的袋子,每个球上写有一个整数。第一名玩家伸手随机从中抽取一个球(所有球被抽中的概率相等)——该球上所写的数字即为矩形的宽度(单位:米)。该球不再放回袋中;第二名玩家再从袋中随机抽取另一个球——该球上所写的数字即为矩形的高度(单位:米)。若该矩形的面积大于或等于某个阈值 p 平方米,则两名玩家获胜;否则失败。
该游戏的组织者正试图为 p 选取一个合适的值,使得情侣获胜的概率既不太高也不太低。但由于他们计数速度较慢,因此聘请你来回答一些问题。你将获得一个列表,其中包含所有球上所写的数字;组织者希望知道:对于不同的 p 值,有多少种“获胜的球对”?注意:若两个球对在第一个球或第二个球上存在差异,则认为它们是不同的球对;即使两个不同的球上写着相同的数字,它们也被视为不同的球。
输入格式
The input begins with a single positive integer n in its own line (1 ≤ n ≤ 106).
The second line contains n positive integers — the i-th number in this line is equal to a__i (1 ≤ a__i ≤ 3·106), the number written on the i-th ball.
The next line contains an integer m (1 ≤ m ≤ 106), 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·106) in the j-th question you are being asked.
输入的第一行包含一个正整数 n(1≤n≤106)。
第二行包含 n 个正整数——该行中第 i 个数等于 ai(1≤ai≤3⋅106),即第 i 个球上所写的数字。
接下来一行包含一个整数 m(1≤m≤106),表示你需回答的问题数量。
随后一行包含 m 个正整数——该行中第 j 个数等于第 j 个问题中的参数 p(1≤p≤3⋅106)。
输出格式
For each question, print the number of winning pairs of balls that exist for the given value of p in the separate line.
对于每个问题,在单独的一行中输出给定 p 值下存在的获胜球对的数量。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?