【構造】 FZU 2140 Forever 0.5,fzu2140

來源:互聯網
上載者:User

【構造】 FZU 2140 Forever 0.5,fzu2140

點擊開啟連結

題意:輸入N,表示有N個點,

要求:

1.任意兩點的距離≤ 1.0

2.每個點與原點的距離≤1.0

3.有N對點間的距離=1.0

4.N個點形成的面積≥0.5 ≤0.75


可以先取一個以原點為頂點,另外兩個點在單位圓上的正三角形


其他的點就在圓弧BC上 

將BC等分

而且N==4時 第四個點必須要在BC中點上

#include <cstdio>#include <cstdlib>#include <cstring>#include <climits>#include <cctype>#include <cmath>#include <string>#include <sstream>#include <iostream>#include <algorithm>#include <iomanip>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#include <set>#include <map>typedef long long LL;typedef long double LD;const double eps=1e-8;#define pi acos(-1.0)#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1typedef pair<int, int> PI;typedef pair<int, PI> PP;#ifdef _WIN32#define LLD "%I64d"#else#define LLD "%lld"#endif//#pragma comment(linker, "/STACK:1024000000,1024000000")//LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;}//inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;}//inline void print(LL x){printf(LLD, x);puts("");}//inline void read(double &x){char c = getchar();while(c < '0') c = getchar();x = c - '0'; c = getchar();while(c >= '0'){x = x * 10 + (c - '0'); c = getchar();}}//inline void sc(LL &x){scanf(LLD, &x);}int main(){    int n,t;    cin>>t;    while(t--)    {        cin>>n;        if(n<4)            printf("No\n");        else        {            printf("Yes\n");            printf("%.6lf %.6lf\n",0.0,0.0);            printf("%.6lf %.6lf\n",1.0,0.0);            printf("%.6lf %.6lf\n",0.5,sqrt(3.0)/2.0);            double st;            for(int i=1;i<=n-3;i++)            {                st=(pi/3.0/(n-2))*i;                double xx=cos(st);                double yy=sqrt(1-xx*xx);                printf("%.6lf %.6lf\n",xx,yy);            }        }    }    return 0;}


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.