牛客國慶集訓派對Day2 魔法陣
阿新 • • 發佈:2018-12-13
題意: 給出3個點,確定一個正三角形,每個三角形的頂點一一對應一個給出的點,使對應的最大距離最小。
題解:
官方的
程式碼:
#include<bits/stdc++.h> #define N 1010 #define INF 0x3f3f3f3f #define eps 1e-10 #define pi acos(-1.0) #define mod 998244353 #define LL long long #define pb push_back #define cl clear #define si size #define lb lower_bound #define ub upper_bound #define mem(x) memset(x,0,sizeof x) #define sc(x) scanf("%d",&x) #define scc(x,y) scanf("%d%d",&x,&y) #define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z) using namespace std; struct Point { double x,y; Point(double x=0,double y=0):x(x),y(y){}; friend Point operator - (Point a,Point b) { return Point(a.x-b.x,a.y-b.y); } friend Point operator + (Point a,Point b) { return Point(a.x+b.x,a.y+b.y); } friend Point operator * (Point a,double p) { return Point(a.x*cos(p)-a.y*sin(p),a.x*sin(p)+a.y*cos(p)); } double dis () { return sqrt(x*x+y*y); } }a[4]; int main() { int T,tt=0; sc(T); while(T--) { for (int i=0;i<3;i++) cin>>a[i].x>>a[i].y; Point t=(a[1]-a[2])*(pi/3)+a[2]-a[0]; double ans=t.dis(); t=(a[2]-a[1])*(pi/3)+a[1]-a[0]; ans=min(ans,t.dis()); printf("Case #%d: %.7f\n", ++tt,ans/3); } }