CF283D.Cows and Cool Sequences
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bessie and the cows have recently been playing with "cool" sequences and are trying to construct some. Unfortunately they are bad at arithmetic, so they need your help!
A pair (x,y) of positive integers is "cool" if x can be expressed as the sum of y consecutive integers (not necessarily positive). A sequence (a1,a2,...,an) is "cool" if the pairs (a1,a2),(a2,a3),...,(an−1,an) are all cool.
The cows have a sequence of n positive integers, a1,a2,...,an . In one move, they may replace some ai with any other positive integer (there are no other limits on the new value of ai ). Determine the smallest number of moves needed to make the resulting sequence cool.
输入格式
The first line contains a single integer, n ( 2<=n<=5000 ). The next line contains n space-separated integers, a1,a2,...,an ( 1<=ai<=1015 ).
Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
输出格式
A single integer, the minimum number of ai that must be changed to make the sequence cool.
输入输出样例
输入#1
3 6 4 1
输出#1
0
输入#2
4 20 6 3 4
输出#2
2
说明/提示
In the first sample, the sequence is already cool, so we don't need to change any elements. In the second sample, we can change a2 to 5 and a3 to 10 to make (20, 5, 10, 4) which is cool. This changes 2 elements.