sicily 1012.Stacking Cylinders
来源:互联网 发布:淘宝搞笑夸张好评 编辑:程序博客网 时间:2024/04/29 16:14
解题思路与1206一致
#include <iostream>#include <vector>#include <algorithm>#include <cmath>using namespace std;struct circle{ double x; double y;};bool com(circle a,circle b){ return a.x < b.x;}int main(){ int n; while(cin >> n && n != 0) { vector<circle> data(n * (n + 1) / 2); for(int i = 0;i < n;i++) { cin >> data[i].x; data[i].y = 1.0; } sort(data.begin(),data.begin() + n,com); int count = n; for(int i = n; i > 0;i--) { for(int j = 0;j < i - 1;j++) { double m1 = data[count - i + 1].x - data[count - i].x; double m2 = data[count - i + 1].y - data[count - i].y; double a1 = atan(m2 / m1); double a2 = acos(sqrt(m1 * m1 + m2 * m2) / 2 / 2); double a = a1 + a2; data[count].x = data[count - i].x + 2 * cos(a); data[count].y = data[count - i].y + 2 * sin(a); count++; } } cout.precision(4); cout << fixed << data[data.size() - 1].x << " " << fixed <<data[data.size() - 1].y << endl; } return 0;}
- Sicily.1012. Stacking Cylinders
- sicily 1012.Stacking Cylinders
- [sicily online]1012. Stacking Cylinders
- sicily 1206. Stacking Cylinders
- Sicily 1206 Stacking Cylinders
- sicily 1206.Stacking Cylinders
- sicily 1206. Stacking Cylinders
- sicily 1012/1206 Stacking Cylinders
- 1206. Stacking Cylinders & 1012. Stacking Cylinders
- 1012. Stacking Cylinders
- 1012. Stacking Cylinders (几何题)
- 1012 Stacking Cylinders
- 1012 Stacking Cylinders
- 3446: Stacking Cylinders
- SOJ 1012 Stacking Cylinders
- 1206. Stacking Cylinders
- ZOJ 2403 Stacking Cylinders
- Stacking Cylinders(poj2194)
- Handler和HandlerThread
- gcc中的内嵌汇编语言(Intel i386平台)
- 返回给定数据的“反序数"
- LeetCode Container With Most Water
- PHP阅读邮件
- sicily 1012.Stacking Cylinders
- 分治 Divide and Conquer 局部最小值 local optimal 棋盘问题
- 今天去了巨人网络笔试
- 分享 VB 学习代码
- Spring事务传播特性实例解析
- 寻找丑数-算法-java语言
- Linux 用 strace调试程序
- C语言单向链表的创建、释放、插入、删除、翻转操作练习
- UVA 10499 The Land of Justice