栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1679 Telescope

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1679 Telescope

#include <cstdio>#include <algorithm> #include <cstring>#include <cmath>using namespace std;const double PI = 3.1415926535898; struct Point{       double x, y;       Point(double xx = 0.0, double yy = 0.0):x(xx), y(yy){} };double det(double x1, double y1, double x2, double y2){        return (x1 * y2) - (x2 * y1);} inline double cross(Point a, Point b, Point c){       return  det(b.x - a.x, b.y - a.y, c.x - a.x, c.y - a.y);}double f[50][50][50];int main(){    double p;     Point a[50];    int n, m;     while (scanf("%d %d", &n, &m) == 2 && (n + m)){          for (int i = 0; i < n; i++){   scanf("%lf", &p);   a[i] = Point(cos(p * 2 * PI), sin(p * 2 * PI));          }          memset(f, 0, sizeof(f));for (int k = 3; k <= m; k++){       for (int i = 0; i < n; i++){        for (int j = (i + 2) % n; j != i; j++, j %= n){ for (int t = (i + 1)%n; t != j; t++, t %= n){     f[i][j][k] = max(f[i][t][k - 1] + cross(a[i], a[t], a[j]) / 2, f[i][j][k]); }        }      }          }double ans = 0.0;          for (int i = 0; i < n; i++){        for (int j = (i + 2) % n; j != i; j++, j %= n){ ans = max(ans, f[i][j][m]);        }          }printf("%.6fn", ans);      }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/377657.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号