CF283D.Cows and Cool Sequences

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

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 (_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.

贝茜和奶牛最近一直在玩“酷”序列,并试图构造一些。但不幸的是,它们不擅长算术,因此需要你的帮助!

若正整数对 (x, y)(x,\,y) 满足 xx 可表示为 yy 个连续整数(不一定为正)之和,则称该对为“酷”的。若序列 (a1, a2, ..., an)(a_1,\,a_2,\,...,\,a_n) 中所有相邻对 (a1, a2), (a2, a3), ..., (an−1, an)(a_1,\,a_2),\,(a_2,\,a_3),\,...,\,(a_{n-1},\,a_n) 均为“酷”的,则称该序列为“酷”序列。

奶牛有一个长度为 nn 的正整数序列 a1, a2, ..., ana_1,\,a_2,\,...,\,a_n。在一次操作中,它们可将某个 aia_i 替换为任意其他正整数(对新值 aia_i 无其他限制)。请确定使最终序列变为“酷”序列所需的最少操作次数。

输入格式

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 ≤ 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.

第一行包含一个整数 $ n (( 2 \leq n \leq 5000 $)。第二行包含 $ n $ 个以空格分隔的整数 $ a_1,,a_2,,\dots,,a_n (( 1 \leq a_i \leq 10^{15} $)。

在 C++ 中,请勿使用 %lld 格式说明符读取或写入 64 位整数。推荐使用 cin、cout 流,或 %I64d 格式说明符。

输出格式

A single integer, the minimum number of a__i that must be changed to make the sequence cool.

一个整数,表示为使该序列变为“酷序列”所需修改的 a__i 的最小个数。

输入输出样例

  • 输入#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.

在第一个样例中,序列已经是“酷”的,因此我们无需修改任何元素。在第二个样例中,我们可以将 a2a_2 改为 5、a3a_3 改为 10,从而得到 (20,5,10,4)(20, 5, 10, 4),该序列是“酷”的。这共修改了 2 个元素。

输入解题思路,AI测评打分。不知道怎么写?

首页