A8913 | Cows and Cool Sequences
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $(a_{1},a_{2},...,a_{n})$ is "cool" if the pairs $(a_{1},a_{2}),(a_{2},a_{3}),...,(a_{n-1},a_{n})$ are all cool.
The cows have a sequence of $n$ positive integers, $a_{1},a_{2},...,a_{n}$ . In one move, they may replace some $a_{i}$ with any other positive integer (there are no other limits on the new value of $a_{i}$ ). Determine the smallest number of moves needed to make the resulting sequence cool.
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 $(a_{1},a_{2},...,a_{n})$ is "cool" if the pairs $(a_{1},a_{2}),(a_{2},a_{3}),...,(a_{n-1},a_{n})$ are all cool.
The cows have a sequence of $n$ positive integers, $a_{1},a_{2},...,a_{n}$ . In one move, they may replace some $a_{i}$ with any other positive integer (there are no other limits on the new value of $a_{i}$ ). 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, $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=10^{15}$ ).
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.
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 $a_{i}$ 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 $a_{2}$ to 5 and $a_{3}$ to 10 to make (20, 5, 10, 4) which is cool. This changes 2 elements.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted