1148: 轻拍牛头 BZOJ1607

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:12 Solved:7

Description

It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 100,000) cows conveniently numbered 1..N to sit in a circle (so that cow i [except at the ends] sits next to cows i-1 and i+1; cow N sits next to cow 1). Meanwhile, Farmer John fills a barrel with one billion slips of paper, each containing some integer in the range 1..1,000,000.

Each cow i then draws a number A_i (1 <= A_i <= 1,000,000) (which is not necessarily unique, of course) from the giant barrel. Taking turns, each cow i then takes a walk around the circle and pats the heads of all other cows j such that her number A_i is exactly

divisible by cow j's number A_j; she then sits again back in her original position.

The cows would like you to help them determine, for each cow, the number of other cows she should pat.

今天是贝茜的生日,为了庆祝自己的生日,贝茜邀你来玩一个游戏.

贝茜让N(1≤N≤100000)头奶牛坐成一个圈.除了1号与N号奶牛外,i号奶牛与i-1号和i+1号奶牛相邻.N号奶牛与1号奶牛相邻.农夫约翰用很多纸条装满了一个桶,每一张包含了一个不一定是独一无二的1到1,000,000的数字.

接着每一头奶牛i从中取出一张纸条Ai.每头奶牛轮流走上一圈,同时拍打所有手上数字能整除在自己纸条上的数字的牛的头,然后做回到原来的位置.牛们希望你帮助他们确定,每一头奶牛需要拍打的牛.

Input

第一行包含一个整数 N;

接下来第二到第 N+1 行每行包含一个整数 Ai。


Output

第一到第 N 行,第 i 行的输出表示第 i 头奶牛要拍打的牛数量。

Sample Input Copy

5
2
1
2
3
4

Sample Output Copy

2
0
2
1
3

HINT

对于全部数据,1≤N≤106




视频讲解

Source/Category