CF1632D.New Year Concert
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
New Year is just around the corner, which means that in School 179, preparations for the concert are in full swing.
There are n classes in the school, numbered from 1 to n , the i -th class has prepared a scene of length ai minutes.
As the main one responsible for holding the concert, Idnar knows that if a concert has k scenes of lengths b1 , b2 , … , bk minutes, then the audience will get bored if there exist two integers l and r such that 1≤l≤r≤k and gcd(bl,bl+1,…,br−1,br)=r−l+1 , where gcd(bl,bl+1,…,br−1,br) is equal to the greatest common divisor (GCD) of the numbers bl , bl+1 , … , br−1 , br .
To avoid boring the audience, Idnar can ask any number of times (possibly zero) for the t -th class ( 1≤t≤k ) to make a new scene d minutes in length, where d can be any positive integer. Thus, after this operation, bt is equal to d . Note that t and d can be different for each operation.
For a sequence of scene lengths b1 , b2 , … , bk , let f(b) be the minimum number of classes Idnar has to ask to change their scene if he wants to avoid boring the audience.
Idnar hasn't decided which scenes will be allowed for the concert, so he wants to know the value of f for each non-empty prefix of a . In other words, Idnar wants to know the values of f(a1) , f(a1 , a2) , … , f(a1 , a2 , … , an) .
输入格式
The first line contains a single integer n ( 1≤n≤2⋅105 ) — the number of classes in the school.
The second line contains n positive integers a1 , a2 , … , an ( 1≤ai≤109 ) — the lengths of the class scenes.
输出格式
Print a sequence of n integers in a single line — f(a1) , f(a1 , a2) , … , f(a1 , a2 , … , an) .
输入输出样例
输入#1
1 1
输出#1
1
输入#2
3 1 4 2
输出#2
1 1 2
输入#3
7 2 12 4 8 18 3 6
输出#3
0 1 1 1 2 2 2
说明/提示
In the first test we can change 1 to 2 , so the answer is 1 .
In the second test:
- [1] can be changed into [2] ,
- [1,4] can be changed into [3,4] ,
- [1,4,2] can be changed into [2,3,2] .