Pagini recente » Cod sursa (job #228614) | Cod sursa (job #970018) | Cod sursa (job #105719) | Cod sursa (job #472045) | Cod sursa (job #1563574)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
vector<long long> r;
int main()
{
ifstream f("reguli.in");
ofstream g("reguli.out");
int n, m = 1;
long long x1, x2; f >> n >> x1 >> x2;
r.push_back(x2 - x1); x1 = x2;
for(int i = 2; i < n; i ++) {
f >> x2;
if(r[ (i - 1) % m] != (x2 - x1)) {
int in = m, aux = i - 1;
while(m < aux) {
for(int j = 0; j < in && m < aux; j ++, m ++)
r.push_back(r[j]);
}
r.push_back(x2 - x1); m ++;
}
x1 = x2;
}
g << r.size() << "\n";
for(int i = 0; i < r.size(); i ++) g << r[i] << "\n";
return 0;
}