主要就是将圆离散化,剩下的都好办
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; #define add 0.005 double x[150],y[150]; int main() { int t,n; scanf("%d",&t); x[0] = y[0] = 0; x[1] = 1,y[1] = 0; x[2] = 0.5,y[2] = sqrt(0.75); x[3] = 0.5,y[3] = y[2]-1; for(int i = 4;i <= 100;i++) { x[i] = 0.5 + (i-3) * add; y[i] = sqrt(1 - x[i]*x[i]); } while(t--) { scanf("%d",&n); if(n <= 3) { puts("No"); continue; } puts("Yes"); for(int i = 0;i < n;i++) { printf("%.6lf %.6lf ",x[i],y[i]); } } }