Pagini recente » Cod sursa (job #349111) | Cod sursa (job #808349) | Cod sursa (job #3127276) | Cod sursa (job #2513973) | Cod sursa (job #1223690)
#include <cstdio>
#define NMAX 500002
long long x[NMAX];
int p[NMAX];
int n,i,aux;
int main()
{
freopen("reguli.in","r",stdin);
freopen("reguli.out","w",stdout);
scanf("%d",&n);
for(i=0;i<n;++i)
scanf("%lld",&x[i]);
aux=0;
for(i=n-1;i>0;--i)
x[i]=x[i]-x[i-1];
--n;
for(i=2;i<=n;++i)
{
while(x[aux+1]!=x[i]&&aux)
aux=p[aux];
if(x[aux+1]==x[i])
++aux;
p[i]=aux;
}
n=n-p[n];
printf("%d\n",n);
for(i=1;i<=n;++i)
printf("%lld\n",x[i]);
return 0;
}