1. 程式人生 > 實用技巧 >P5600 【XR-4】尺規作圖

P5600 【XR-4】尺規作圖

P5600 【XR-4】尺規作圖

做了一天的提答題,還是NOIP前冒著生命危險咕掉模擬賽做的。

NOIP2020 rp++!!!

不忍心丟掉答案,存一下吧,不會的話自己把點畫出來就好了,可以用 GeoGebra ,我就是用這個做的。

前八個點還是挺有價值的,後面兩個做不做隨便,就是拿那個軟體亂試,沒啥意思。

T1

3
1 0 0 1 0
1 1 0 0 0
2 0.5 0.866025404 0.5 -0.866025404

T2

3
1 1 0 5.23124577 4.31624417
1 0 0 5.23124577 4.31624417
2 5.23124577 4.31624417 5.23124577 -4.31624417

T3

5
1 0 0 1 0
1 1 0 0 0
2 0.5 0.8660254038 0.5 -0.8660254038
1 0.5 1 0.5 0
2 -0.4916198487 0.8708099244 0.9916198487 0.1291900756

T4

10
1 1 0 0 0
1 2 0 0 0
1 4 0 0 0
1 8 0 0 0
1 16 0 0 0
1 32 0 0 0
1 64 0 0 0
1 128 0 0 0
1 256 0 0 0
1 512 0 0 0

T5

10
1 1 0 0 0
1 2 0 0 0
1 4 0 0 0
1 0 0 8 0
1 -8 0 8 0
1 8 0 -24 0
1 40 0 -24 0
1 104 0 -24 0
1 232 0 -24 0
1 488 0 -24 0

T6

27
2 0 0 0 1
1 0 1.0000000000 0 0.0000000000
2 -0.8660254040 0.5000000000 0.8660254040 0.5000000000
1 0 0.0000000000 0 0.5000000000
2 -0.4841229187 0.1250000000 0.4841229187 0.1250000000
1 0 0.5000000000 0 0.1250000000
2 -0.3476343052 0.3593750000 0.3476343052 0.3593750000
1 0 0.5000000000 0 0.3593750000
2 -0.1392276034 0.4802246094 0.1392276034 0.4802246094
1 0 0.3593750000 0 0.4802246094
2 -0.1091245016 0.4113025665 0.1091245016 0.4113025665
1 0 0.4802246094 0 0.4113025665
2 -0.0660604790 0.4605710581 0.0660604790 0.4605710581
1 0 0.4113025665 0 0.4605710581
2 -0.0460139752 0.4289122032 0.0460139752 0.4289122032
1 0 0.4113025665 0 0.4289122032
2 -0.0174653775 0.4135522046 0.0174653775 0.4135522046
1 0 0.4289122032 0 0.4135522046
2 -0.0138222866 0.4222133268 0.0138222866 0.4222133268
1 0 0.4222133268 0 0.4135522046
2 -0.0068365531 0.4275309935 0.0068365531 0.4275309935
1 0 0.4275309935 0 0.4135522046
2 -0.0132070592 0.4229504793 0.0132070592 0.4229504793
1 0 0.4135522046 0 0.4229504793
2 -0.0078948025 0.4186512879 0.0078948025 0.4186512879
1 0 0.4229504793 0 0.4186512879
2 -0.0041853462 0.4219671581 0.0041853462 0.4219671581

code

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sz(v) (int)v.size()
typedef long long LL;
typedef long double db;
template<class T>bool ckmax(T&x,T y){return x<y?x=y,1:0;}
template<class T>bool ckmin(T&x,T y){return x>y?x=y,1:0;}
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define per(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
const db eps=1e-9;
const db X=0.90660864,Y=0.42197248;
struct cir{
	db x,r;
	cir(){x=r=0;}
	cir(db x_,db r_){x=x_,r=r_;}
}c[50];
db inter_circle(cir a,cir b){
	if(fabs(a.x-b.x)<eps)return a.x;
	db cos_=((b.x-a.x)*(b.x-a.x)+a.r*a.r-b.r*b.r)/(2*(b.x-a.x)*a.r);
	// cerr<<"cir:"<<a.x<<' '<<a.r<<' '<<b.x<<' '<<b.r<<' '<<a.x+a.r*cos_<<'\n';
	return a.x+a.r*cos_;
}
db Sqrt(db x){
	db l=0,r=100;
	while(r-l>eps){
		db mid=(l+r)/2;
		if(mid*mid<x+eps)l=mid;
		else r=mid;
	}
	return l;
}
signed main(){
	puts("40");
	puts("2 0 0 0 1");
	c[0]=cir(0,1);
	db l=0,r=1;
	for(int T=1;T<=19;++T){
		db mi=114514;pair<int,int>id=mkp(-1,-1);
		// if(T&1)printf("1 0 %.10Lf 0 %.10Lf\n",r,l),c[T]=cir(r,r-l);
		// else printf("1 0 %.10Lf 0 %.10Lf\n",l,r),c[T]=cir(l,r-l);
		cir c1=cir(r,r-l),c2=cir(l,r-l);
		rep(i,0,T-1){
			db tmp=inter_circle(c1,c[i]);
			if(fabs(l-tmp)>eps&&fabs(r-tmp)>eps&&ckmin(mi,fabs(Y-tmp)))id=mkp(i,0);
			tmp=inter_circle(c2,c[i]);
			if(fabs(l-tmp)>eps&&fabs(r-tmp)>eps&&ckmin(mi,fabs(Y-tmp)))id=mkp(i,1);
		}
		c[T]=id.se?c2:c1;
		db tmp=inter_circle(c[T],c[id.fi]);
		// cerr<<id.fi<<' '<<id.se<<' '<<tmp<<'\n';
		printf("1 0 %.10Lf 0 %.10Lf\n",c[T].x,l+r-c[T].x);
		if(tmp<=Y)l=tmp;else r=tmp;
		db tmp2=Sqrt(c[id.fi].r*c[id.fi].r-(c[id.fi].x-tmp)*(c[id.fi].x-tmp));
		printf("2 %.10Lf %.10Lf %.10Lf %.10Lf\n",-tmp2,tmp,tmp2,tmp);
		if(fabs(tmp-Y)<1e-5)break;
		// cerr<<"debug:"<<l<<' '<<r<<'\n';
	}
	// rep(i,0,19)cerr<<c[i].x<<' '<<c[i].r<<'\n';
}

T7

5
1 12.34441574 0.00000000 5.16457145 9.12243565
1 5.16457145 9.12243565 12.34441574 0.00000000
2 0 0 16.6547546123 10.7791453754
1 0.7454403075 0.4824573901 12.34441574 0.00000000
2 5.16457145 9.12243565 6.1271076677 -9.8037786874

T8

5
1 0 0 5.16457145 9.12243565
1 12.34441574 0.00000000 5.16457145 9.12243565
1 0.7354107776 0 10.4829208931 0
1 10.4829208931 0 0.7354107776 0
2 5.6091658353 8.4415913837 5.6091658353 -8.4415913837

T9

6
1 0 0 10.64978745 0.00000000
1 10.64978745 0.00000000 0 0
1 -10.64978745 0.00000000 0 0
1 5.324893725 9.2229864766 21.29957490 0
2 -2.8891429893 -7.2931728544 -5.324893725 9.2229864766
1 -3.9647169663 0 -10.64978745 0

T10

9
1 0 0 10.64978745 0.00000000
1 10.64978745 0.00000000 0 0
1 -10.64978745 0.00000000 0 0
1 5.324893725 9.2229864766 21.29957490 0
2 -2.8891429893 -7.2931728544 -5.324893725 9.2229864766
1 -3.9647169663 0 -10.64978745 0
2 5.324893725 9.2229864766 -2.1668572419 6.4387784412
2 21.2995749 0 -13.0855381857 10.3675016799
1 -6.5503572407 8.3970704861 22.6154412357 15.6487848684