Language: C++

#include <stdio.h>
#include <math.h>
#include <vector>

#define EPS 1e-3
#define REP(i,n) for(int i = 0; i < (n); i++)

using namespace std;

//FILE *in = freopen("input.txt", "r", stdin);
//FILE *out = freopen("output.txt", "w", stdout);

int n;
long double data[10];

void input() {
	for(int i = 0; i < n + 3; i++) {
		scanf("%Lf", &data[i]);
	}
}

vector<long double> sweep_out(vector<vector<long double>> mat_org) {
	int N = mat_org.size();
	vector<vector<long double>> mat;
	REP(i, mat_org.size()) {
		mat.push_back(vector<long double>(mat_org[i].size()));
		REP(j, mat_org[i].size()) {
			mat[i][j] = mat_org[i][j];
		}
	}

	vector<long double> ans(N);
	REP(i, N) {
		if(abs(mat[i][i]) < EPS) {
			for(int j = i+1; j < N; j++) {
				if(abs(mat[i][j]) >= EPS) {
					swap(mat[i], mat[j]);
					break;
				}
			}
		}
		for(int j = N; j >= i; j--){
			mat[i][j] /= mat[i][i];
		}
		REP(j,N) {
			if(i == j) continue;
			long double t = mat[j][i];
			REP(k, N+1) {
				mat[j][k] -= mat[i][k] * t;
			}
		}
	}
	REP(i, N) {
		ans[i] = mat[i][N];
	}
	return ans;
}

void process() {
	vector<vector<long double>> mm(n+3);
	REP(i,n+3){
		mm[i].resize(n+2);
		int q = 1;
		REP(j,n+1){
			mm[i][j] = q;
			q *= i;
		}
		mm[i][n+1] = data[i];
	}

	int cnti[10];
	memset(cnti, 0, sizeof(cnti));

	int cntp;

	REP(i, n+3) {
		int cnta = 1;
		vector<long double> prev;
		for(int j = 0; j < n+3; j++) {
			if(i == j) continue;
			int cnt = 0;
			vector<vector<long double>> mat;
			for(int k = 0; k < n+3; k++) {
				if(k == i || k == j) continue;
				mat.push_back(mm[k]);
			}
			auto ans = sweep_out(mat);
			if(prev.empty()) {
				prev = ans;
			}
			else {
				for(int k = 0; k < n+1; k++) {
					if(abs(prev[k] - ans[k]) < EPS) {
						++cnt;
					}
				}
				if(cnt >= n) {
					++cnta;
				}
			}
		}
		if(cnta >= n+2) {
			printf("%d\n", i);
		}
	}
}

int main() {
	while(true){
		scanf("%d", &n);
		if(n == 0) break;
		input();
		process();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void input()':
a.cc:18:31: error: reference to 'data' is ambiguous
   18 |                 scanf("%Lf", &data[i]);
      |                               ^~~~
In file included from /usr/include/c++/14/vector:69,
                 from a.cc:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:14:13: note:                 'long double data [10]'
   14 | long double data[10];
      |             ^~~~
a.cc: In function 'void process()':
a.cc:68:30: error: reference to 'data' is ambiguous
   68 |                 mm[i][n+1] = data[i];
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:14:13: note:                 'long double data [10]'
   14 | long double data[10];
      |             ^~~~
a.cc:72:9: error: 'memset' was not declared in this scope
   72 |         memset(cnti, 0, sizeof(cnti));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 |