#include #include #include #include bool tstSeq(FILE* f); const double EPS = 0.0001; int main() { FILE* in = fopen("input.txt", "r"); if (in == NULL) { perror("Could not open input file"); return (-1); } bool res = tstSeq(in); fclose(in); FILE* out = fopen("output.txt", "w"); if (in == NULL) { perror("Could not open output file"); return (-1); } if (res) fprintf(out, "true\n", res); else fprintf(out, "false\n", res); fclose(out); return 0; } bool tstSeq(FILE* f) { double c1, c2, c3, d; if (fscanf(f, "%lf%lf%lf%lf", &c1, &c2, &c3, &d) < 4) { fprintf(stderr, "Incorrect input file\n"); exit(-1); } double x1 = 0., x2 = 0., x3 = 0.; bool res = true; int len = 0; int a; while (fscanf(f, "%d", &a) == 1) { x1 = x2; x2 = x3; x3 = a; ++len; if (len >= 3) { if (fabs(x1*c1 + x2*c2 + x3*c3 - d) >= EPS) { res = false; break; } } } return (res && len >= 3); }