CF691F.Couple Cover

普及/提高-

通过率:0%

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 nn 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 pp square meters, the players win. Otherwise, they lose.

The organizers of the game are trying to select an appropriate value for pp 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 pp . 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 nn in its own line ( 1<=n<=1061<=n<=10^{6} ).

The second line contains nn positive integers — the ii -th number in this line is equal to aia_{i} ( 1<=ai<=31061<=a_{i}<=3·10^{6} ), the number written on the ii -th ball.

The next line contains an integer mm ( 1<=m<=1061<=m<=10^{6} ), the number of questions you are being asked.

Then, the following line contains mm positive integers — the jj -th number in this line is equal to the value of pp ( 1<=p<=31061<=p<=3·10^{6} ) in the jj -th question you are being asked.

输出格式

For each question, print the number of winning pairs of balls that exist for the given value of pp 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
    
首页