sgu251:Polymania(构造)
2015-06-04 21:24
323 查看
题目大意:
~~~~~~给出平面上n(3≤n≤8)n(3\leq n\leq 8)个点,每个点有一个坐标((未知))和正整数权值RiR_i,其中Rn−1=RnR_{n-1}=R_n,给出一组坐标构造,使得任意三个点构成的三角形面积为这三个点的权值和。
分析:
~~~~~~我们以最后两个有相等权值的点为基来考虑。
~~~~~~满足条件的一组构造必定满足如下条件:
~~~~~~1.1.因为权值均为正整数,所以没有三点共线;
~~~~~~2.2.构造必定形如:
~~~~~~即除Rn−1,RnR_{n-1},R_n外的点必定在上或下的平行线上((证明很显然));
~~~~~~3.3.在22的基础上,在上下两条平行线上分别任取一个点,这两个点连线段必过Rn−1,RnR_{n-1},R_n的中点。
~~~~~~综上所述,当n>4n>4时,一定无解;
~~~~~~~~~~~~~~~~~~~~~~当n=4n=4时,若R1+R2=R3+R4R_1+R_2=R_3+R_4,那么可以把R1,R2R_1,R_2上下放;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~若R1=R2R_1=R_2,可以两个都放上面;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~否则无解;
~~~~~~~~~~~~~~~~~~~~~~当n=3n=3时,一定有解,随便构造即可。
AC code:
~~~~~~给出平面上n(3≤n≤8)n(3\leq n\leq 8)个点,每个点有一个坐标((未知))和正整数权值RiR_i,其中Rn−1=RnR_{n-1}=R_n,给出一组坐标构造,使得任意三个点构成的三角形面积为这三个点的权值和。
分析:
~~~~~~我们以最后两个有相等权值的点为基来考虑。
~~~~~~满足条件的一组构造必定满足如下条件:
~~~~~~1.1.因为权值均为正整数,所以没有三点共线;
~~~~~~2.2.构造必定形如:
~~~~~~即除Rn−1,RnR_{n-1},R_n外的点必定在上或下的平行线上((证明很显然));
~~~~~~3.3.在22的基础上,在上下两条平行线上分别任取一个点,这两个点连线段必过Rn−1,RnR_{n-1},R_n的中点。
~~~~~~综上所述,当n>4n>4时,一定无解;
~~~~~~~~~~~~~~~~~~~~~~当n=4n=4时,若R1+R2=R3+R4R_1+R_2=R_3+R_4,那么可以把R1,R2R_1,R_2上下放;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~若R1=R2R_1=R_2,可以两个都放上面;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~否则无解;
~~~~~~~~~~~~~~~~~~~~~~当n=3n=3时,一定有解,随便构造即可。
AC code:
[code]#include <cstdio> #include <cmath> typedef double DB; using namespace std; const int MAXN = 5; const DB eps = 1e-8; int n; DB a[MAXN]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif scanf("%d", &n); if(n > 4) puts("NO"); else { for(int i = 1; i <= n; ++i) scanf("%lf", a+i); if(n == 4) { if(fabs(a[1]+a[2]-a[3]-a[4]) > eps) { if(fabs(a[1]-a[2]) > eps) puts("NO"); else { DB x3 = -10, x4 = 10, x, y; y = (a[1]+a[3]+a[4])*2/(x4-x3); x = (a[1]+a[2]+a[3])*2/y; puts("YES"); printf("%.4lf %.4lf\n", -x/2, y); printf("%.4lf %.4lf\n", x/2, y); printf("%.4lf 0.0000\n", x3); printf("%.4lf 0.0000\n", x4); } } else { DB x3 = -10, x4 = 10, y1, y2; y1 = (a[1]+a[3]+a[4])*2/(x4-x3); y2 = -(a[2]+a[3]+a[4])*2/(x4-x3); puts("YES"); printf("0.0000 %.4lf\n", y1); printf("0.0000 %.4lf\n", y2); printf("%.4lf 0.0000\n", x3); printf("%.4lf 0.0000\n", x4); } } else { DB x2 = -10, x3 = 10, y1; y1 = (a[1]+a[2]+a[3])*2/(x3-x2); puts("YES"); printf("0.0000 %.4lf\n", y1); printf("%.4lf 0.0000\n", x2); printf("%.4lf 0.0000\n", x3); } } #ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif return 0; }
相关文章推荐
- Fibonacci的组合数通项公式
- 软件工程课程意见
- JavaScript读书笔记(3)-操作符、语句和函数
- dnspod的url转发
- spark中各种连接操作以及实用方法
- 移动端开发 根据html的字体大小来设置布局
- 使用Python扫描端口情况
- 图像基本噪声添加函数
- android设置图片自适应控件大小
- React 组件间通信
- 小组间的互评和自评
- 大数据架构:flume-ng+Kafka+Storm+HDFS 实时系统组合
- wordpress开启多站点 (Multisite)功能。
- hdn2050(递推之画直线求区域个数)
- content-type引发的CDN错误
- 用户界面View之ScrollView:个人学习之路(4)
- 算术表达式的转换
- 小记
- 浅谈c++多态性
- P124.39