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.
算是一个提示,其实较为显然,这样放在两个横坐标为 和 的圆之间的圆的横坐标就是 。
那么纵坐标呢?好像现行题解写的不是很清楚。
观察图片,可知放在两个横坐标为 和 的圆之间的圆与这两个圆中任意一个的圆心距离都为 。又知道横坐标为 ,那么距离就是 (不妨 ),然后纵坐标就勾股一下,,解得 ,累加即可,因为题目做了一个非常 666 的保证就是 cylinders at level will never touch cylinders at level ,相当于每次都是分层计算的,然后因为纵坐标是从 开始的所以最后加上 即可。
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 by liuzimingc
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY