CF547C.Mike and Foam

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are nn kinds of beer at Rico's numbered from 11 to nn . ii -th kind of beer has aia_{i} milliliters of foam on it.

Maxim is Mike's boss. Today he told Mike to perform qq queries. Initially the shelf is empty. In each request, Maxim gives him a number xx . If beer number xx is already in the shelf, then Mike should remove it from the shelf, otherwise he should put it in the shelf.

After each query, Mike should tell him the score of the shelf. Bears are geeks. So they think that the score of a shelf is the number of pairs (i,j)(i,j) of glasses in the shelf such that i<j and where is the greatest common divisor of numbers aa and bb .

Mike is tired. So he asked you to help him in performing these requests.

输入格式

The first line of input contains numbers nn and qq ( 1<=n,q<=2×1051<=n,q<=2×10^{5} ), the number of different kinds of beer and number of queries.

The next line contains nn space separated integers, a1,a2,... ,ana_{1},a_{2},...\ ,a_{n} ( 1<=ai<=5×1051<=a_{i}<=5×10^{5} ), the height of foam in top of each kind of beer.

The next qq lines contain the queries. Each query consists of a single integer integer xx ( 1<=x<=n1<=x<=n ), the index of a beer that should be added or removed from the shelf.

输出格式

For each query, print the answer for that query in one line.

输入输出样例

  • 输入#1

    5 6
    1 2 3 4 6
    1
    2
    3
    4
    5
    1
    

    输出#1

    0
    1
    3
    5
    6
    2
    
首页