This commit is contained in:
unlockable
2023-12-25 22:17:54 +08:00
parent 7e4e37d96c
commit 0a20aa752a

View File

@@ -1,5 +1,4 @@
#include <stdio.h>
#include <iostream>
double A[5051] = {0};
double point_xs[101] = {0};
@@ -49,8 +48,9 @@ int main() {
}
if (!found_duplicate) {
point_xs[++valid_point_num] = read_x;
point_xs[valid_point_num] = read_x;
t[valid_point_num] = read_y;
valid_point_num++;
}
}
@@ -58,6 +58,9 @@ int main() {
for (int row = 0; row < valid_point_num; row++) {
set_num(row, 0, 1);
for (int col = 1; col <= row; col++) {
// double prev = get_num(row, col - 1);
// double coefficient = point_xs[row] - point_xs[col - 1];
// set_num(row, col, prev * coefficient);
set_num(row, col, get_num(row, col - 1) * (point_xs[row] - point_xs[col - 1]));
}
}
@@ -72,10 +75,13 @@ int main() {
// Find for highest exponent
int highest = valid_point_num - 1;
for (; highest >= 0; highest++) {
for (; highest >= 0; highest--) {
if (!compare_double(t[highest], 0)) {
break;
}
// if (t[highest] != 0) {
// break;
// }
}
printf("%d\n", highest);