无垢清净光,慧日破诸暗,能伏灾风火,普明照世间。——法华经

Solution - Stacking Cylinders

Link

有一个向量旋转做法,但是我不会。

Note: To help you check your work, the x-coordinate of the center of the top cylinder should be the average of the x-coordinates of the leftmost and rightmost bottom cylinders.

算是一个提示,其实较为显然,这样放在两个横坐标为 x1x2 的圆之间的圆的横坐标就是 x1+x22

那么纵坐标呢?好像现行题解写的不是很清楚。

观察图片,可知放在两个横坐标为 x1x2 的圆之间的圆与这两个圆中任意一个的圆心距离都为 2r=2。又知道横坐标为 x1+x22,那么距离就是 x2x1+x22=x2x12(不妨 x1<x2),然后纵坐标就勾股一下,y2+(x2x12)2=22,解得 y=4(x2x12)2,累加即可,因为题目做了一个非常 666 的保证就是 cylinders at level k will never touch cylinders at level k2,相当于每次都是分层计算的,然后因为纵坐标是从 1 开始的所以最后加上 1 即可。

namespace liuzimingc {
const int N = 1e6 + 5;
#define endl '\n'

int n;
double x[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	while (cin >> n && n) {
		for (int i = 1; i <= n; i++) cin >> x[i];
		sort(x + 1, x + 1 + n);
		double sum = 1;
		for (int i = 1; i < n; i++)
			sum += sqrt(4 - pow((x[i + 1] - x[i]) / 2, 2));
		cout << fixed << setprecision(4) << (x[1] + x[n]) / 2 << " " << sum << endl;
	}
	return 0;
}
} // namespace liuzimingc
posted @   liuzimingc  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
more_horiz
keyboard_arrow_up dark_mode palette
选择主题
点击右上角即可分享
微信分享提示