#P4703. Mike and Foam
Mike and Foam
Mike and Foam
题面翻译
题目描述
是酒吧的调酒师。在酒吧,他们将啤酒杯放在一个特殊的架子上。在酒吧,有种啤酒编号从到。第瓶啤酒上面有 毫升的泡沫。
是的老板。今天他让回答个查询。最初架子是空的。在每个操作中,给他一个编号。如果编号为的啤酒已经在架子上,那么应该从架子上取下它,否则他应该把它放在架子上。
每次询问后,应该告诉他架子的分数。他们认为货架的分数是满足并且的数对的个数。
现在很累。所以他请你帮他处理这些操作。
输入格式
第一行输入包含数字和(,),不同种类的啤酒数量和查询次数。
下一行包含个由空格分隔的整数,( ),表示各种啤酒顶部的泡沫量。
接下来行一行包含一个查询。每个查询一个整数(),表示应从货架上添加或移除的啤酒的编号。
输出格式
对于每一个查询,用一行输出对应的答案。
题目描述
Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are kinds of beer at Rico's numbered from to . -th kind of beer has milliliters of foam on it.
Maxim is Mike's boss. Today he told Mike to perform queries. Initially the shelf is empty. In each request, Maxim gives him a number . If beer number 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 of glasses in the shelf such that i<j and where is the greatest common divisor of numbers and .
Mike is tired. So he asked you to help him in performing these requests.
输入格式
The first line of input contains numbers and ( ), the number of different kinds of beer and number of queries.
The next line contains space separated integers, ( ), the height of foam in top of each kind of beer.
The next lines contain the queries. Each query consists of a single integer integer ( ), 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
样例输入 #1
5 6
1 2 3 4 6
1
2
3
4
5
1
样例输出 #1
0
1
3
5
6
2