#include #include // ================================ int main(int argc, char* argv[]) // ================================ { int k = atoi(argv[1]), k2=k+k; double u = 2.0*M_PI/(double)k; // printf("k = %d\n\n", k); int a[4], b[4], sa, cnt = 0; double f[4], g[4], ff, gg; for (int i = 1; i < k-3; i++) { a[0] = i; f[0] = cos(i*u); for (int j = i+1; j < k-2; j++) { a[1] = j; f[1] = cos(j*u); // sa = a[0] + a[1]; for (int l = j+1; l < k-1; l++) { a[2] = l; // sa++; // if (sa > k2) continue; f[2] = cos(l*u); for (int m = l+1; m < k; m++) { // int m = k2-a[0]-a[1]-a[2]; // if (m <= a[2]) continue; a[3] = m; // sa += m; f[3] = cos(m*u); if (a[0]+a[1]+a[2]+a[3] != k2) continue; // if (sa != k2) continue; ff = f[0]*f[1]*f[2]*f[3]; for (int p = 1; p < k-3; p++) { b[0] = p; // if (b[0] == a[0] || b[0] == a[1] || b[0] == a[2] || b[0] == a[3]) continue; if (b[0] == i || b[0] == j || b[0] == l || b[0] == m) continue; g[0] = cos(p*u); for (int q = p+1; q < k-2; q++) { b[1] = q; // if (b[1] == a[0] || b[1] == a[1] || b[1] == a[2] || b[1] == a[3]) continue; if (b[1] == i || b[1] == j || b[1] == l || b[1] == m) continue; g[1] = cos(q*u); for (int r = q+1; r < k-1; r++) { b[2] = r; // if (b[2] == a[0] || b[2] == a[1] || b[2] == a[2] || b[2] == a[3]) continue; if (b[2] == i || b[2] == j || b[2] == l || b[2] == m) continue; g[2] = cos(r*u); for (int s = r+1; s < k; s++) { b[3] = s; // if (b[3] == a[0] || b[3] == a[1] || b[3] == a[2] || b[3] == a[3]) continue; if (b[3] == i || b[3] == j || b[3] == l || b[3] == m) continue; g[3] = cos(s*u); if (b[0]+b[1]+b[2]+b[3] != k2) continue; gg = g[0]*g[1]*g[2]*g[3]; if (fabs(ff-gg) > 1.0e-12) continue; cnt++; fprintf(stderr, "%4d %4d %4d %4d -- %4d %4d %4d %4d -- %15.12f %15.12f\n", a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3], ff, gg); } } } } } } } } // timer.stop(false); if (cnt % 2 == 1) { fprintf(stderr, "Wrong cnt = %d for k = %d\n", cnt, k); exit(1); } printf("%d %d", k, cnt/2); printf("\n"); return 0; }