codeforces #519B. Lost Array
程序员文章站
2022-03-02 23:06:07
...
这题看题就知道公式x[i-1]=a[i]+a[i-1],然后让你求哪些k可以一直满足b[j]==bj-i这个k就可以行
#include<bits/stdc++.h>
using namespace std;
int n,k,fl,a[1005],b[1005],c[1005];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i) scanf("%d",a+i),b[i]=a[i]-a[i-1];
for(int i=1;i<=n;++i){
fl=1;
for(int j=i+1;j<=n;++j) if(b[j]!=b[j-i]) {fl=0;break;}
if(fl) c[++k]=i;
}
printf("%d\n",k);
for(int i=1;i<=k;++i) printf("%d ",c[i]);
return 0;
}
推荐阅读
-
Codeforces Round #650 (Div. 3) B. Even Array
-
【递推】Ayoub and Lost Array
-
Codeforces Round #686 (Div. 3) F. Array Partition
-
codeforces D. Game With Array
-
Codeforces Round #643 (Div. 2) D. Game With Array
-
CodeForces - 1454F Array Partition(线段树+二分)
-
Codeforces Round #258 (Div. 2) B. Sort the Array (模拟)
-
C.Good Array (思维) Codeforces Round #521 (Div. 3)
-
Codeforces Round #497 (Div. 2) ---- C Reorder the Array
-
Codeforces 1353 D. Constructing the Array(优先队列)