Cod sursa(job #1382678)
| Utilizator | Data | 9 martie 2015 14:02:23 | |
|---|---|---|---|
| Problema | Reguli | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<fstream>
using namespace std;
long long n, i, j, x, y, a[500003], L, p[500003], ok;
ifstream in("reguli.in");
ofstream out("reguli.out");
int main(){
in>>n;
in>>y;
for(i=2; i<=n; i++){
x=y;
in>>y;
a[i-1]=y-x;
}
for(i=2; i<n; i++){
while(L!=0 && a[i]!=a[L+1])
L=p[L];
if(a[i]==a[L+1])
L++;
p[i]=L;
}
x=n-1-p[n-1];
out<<x<<"\n";
for(i=1; i<=x; i++)
out<<a[i]<<"\n";
return 0;
}
