如下图这是“今日头条杯”首届湖北省大学程序设计竞赛的第一题,作为赛后补题

题目描述:链接点此

这套题的github地址(里面包含了数据,题解,现场排名):点此

Let  be a regualr triangle, and D is a point in the triangle. Given the angle of . Then let AD, CD and BD form a new triangle, what is the size of the three angles?

输入描述:

Input contains multiple cases, please process to the end of input.

For each line in the input, contains three integers, $\alpha, \beta, \gamma$, which are the size of the angel , and in degree.

输出描述:

  1. For each line of input, output one line with three numbers in ascending order, the three angles in the new triangle, your answer will be considered as correct if and only if the relative or absolute error is less than

, If the new triangle cannot be formed, output -1 -1 -1 instead.

题目解析:就是一个等边三角形,然后在等边三角形内有一点D,已知  and  ,求以AD,BD,CD为边构成的三角形的内角。

现场列了三个方程:

但是很难受,解方程解了3个小时,并没有算出来(可能是我数学太弱了),后来想二分,二分角DAB,但是现场wa了,回头补上来,

现在说一种十分简单的方法:

这是不是一个代数题,是一道解题目,我们把三角形ABC逆时针旋转60度,如下图:

就会出现以abc为边构成的三角形PP'C,由于ΔAPP'是等边三角形,所以可以求出三个角分别为  and  减去60度,这是个水题啊。(ORZ,卡了4个小时)

  1. /*
  2. data:2018.04.22
  3. author:gsw
  4. link:https://www.nowcoder.com/acm/contest/104#question
  5. tip:武大校赛--补题
  6. */
  7. #define IO ios::sync_with_stdio(false);
  8. #define ll long long
  9.  
  10. #include<iostream>
  11. #include<string.h>
  12. #include<math.h>
  13. #include<stdio.h>
  14. #include<vector>
  15. #include<algorithm>
  16.  
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. int a,b,c;
  22. while(~scanf("%d%d%d",&a,&b,&c))
  23. {
  24. int ans[];
  25. ans[]=a-;
  26. ans[]=b-;
  27. ans[]=c-;
  28. sort(ans,ans+);
  29. printf("%d %d %d\n",ans[],ans[],ans[]);
  30. }
  31. }

下面会有二分的做法:

对角DAB进行二分,我试了好几次,把所有的优化都做了,要把esp调到1e-12才可以过

然后注意几点优化:把所有的变量定义放在外面,这个优化挺重要的。

  1. /*
  2. data:2018.04.22
  3. author:gsw
  4. link:https://www.nowcoder.com/acm/contest/104#question
  5. tip:武大校赛--补题
  6. */
  7. #define IO ios::sync_with_stdio(false);
  8. #define ll long long
  9.  
  10. #include<iostream>
  11. #include<string.h>
  12. #include<math.h>
  13. #include<stdio.h>
  14. #include<vector>
  15. #include<algorithm>
  16. int a,b,c;
  17. using namespace std;
  18.  
  19. const double expp=1e-;
  20. const double pi=3.14159265358;
  21. const double g3=sqrt()/;
  22. double cosc,x,y,ad,cd,bd,cos_c,th1,th2,mid,ans[];
  23. inline bool judge(double th1)
  24. {
  25. th2=-a-th1;
  26. th1=th1/*pi;th2=th2/*pi;
  27. th1=tan(th1);th2=tan(th2);
  28. x=th2/(th2+th1);
  29. y=x*th1;
  30. //cout<<"x= "<<x<<" "<<y<<endl;
  31. ad=x*x+y*y;
  32. cd=(x-0.5)*(x-0.5)+(y-g3)*(y-g3);
  33. cos_c=(ad+cd-)/(*sqrt(ad*cd));
  34. //cout<<cos_c<<" "<<cosc<<endl;
  35. if(cos_c>cosc)return ;
  36. else return ;
  37. }
  38. inline double ef(double l,double r)
  39. {
  40. while(r-l>expp)
  41. {
  42. mid=(l+r)/;
  43. if(judge(mid))l=mid;
  44. else r=mid;
  45. //cout<<l<<" "<<r<<endl;
  46. }
  47. return l;
  48. }
  49. int main()
  50. {
  51. //freopen("temin.txt","r",stdin);
  52. //freopen("temout.txt","w",stdout);
  53.  
  54. while(~scanf("%d%d%d",&a,&b,&c))
  55. {
  56. cosc=cos((double)c/*pi);
  57. th1=ef(,min(-a,));
  58. th2=-a-th1;
  59. th1=th1/*pi;th2=th2/*pi;
  60. th1=tan(th1);th2=tan(th2);
  61. x=th2/(th2+th1);
  62. y=x*th1;//th2*th1/(th2+th1);
  63. //cout<<x<<" "<<y<<endl;
  64. ad=x*x+y*y;
  65. cd=(x-0.5)*(x-0.5)+(y-g3)*(y-g3);
  66. bd=(x-)*(x-)+y*y;
  67. //cout<<ad<<" "<<cd<<" "<<bd<<endl;
  68. ans[]=acos((ad+cd-bd)/(*sqrt(ad*cd)))/pi*;
  69. ans[]=acos((ad+bd-cd)/(*sqrt(ad*bd)))/pi*;
  70. ans[]=acos((bd+cd-ad)/(*sqrt(bd*cd)))/pi*;
  71. sort(ans,ans+);
  72. printf("%f %f %f\n",ans[],ans[],ans[]);
  73. }
  74. }

再此跟新::

这个优化还是不到位啊,有时t,有时A。时间总是差个几毫秒

A. Srdce and Triangle--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)的更多相关文章

  1. “今日头条杯”首届湖北省大学程序设计竞赛--F. Flower Road

    题目链接:点这 github链接:(包含数据和代码,题解):点这 链接:https://www.nowcoder.com/acm/contest/104/E来源:牛客网 题目描述 (受限于评测机,此题 ...

  2. “今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/D来源:牛客网 题目描述 ...

  3. I. Five Day Couple--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/H来源:牛客网 题目描述 ...

  4. D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 由于系统限制,C题无法在此评测,此题为现场赛的D题 Who killed Cock Robin? I, ...

  5. H. GSS and Simple Math Problem--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)

    题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 Given n positive integers , your task is to calculat ...

  6. “东信杯”广西大学第一届程序设计竞赛(同步赛)H

    链接:https://ac.nowcoder.com/acm/contest/283/H来源:牛客网 题目描述 由于临近广西大学建校90周年校庆,西大开始了喜闻乐见的校园修缮工程! 然后问题出现了,西 ...

  7. 2019年广东工业大学腾讯杯新生程序设计竞赛(同步赛)E-缺席的神官

    链接:https://ac.nowcoder.com/acm/contest/3036/E 来源:牛客网 题目描述 面前的巨汉,让我想起了多年前的那次,但这个巨汉身上散布着让人畏惧害怕的黑雾.即使看不 ...

  8. Minieye杯第十五届华中科技大学程序设计邀请赛现场同步赛 I Matrix Again

    Minieye杯第十五届华中科技大学程序设计邀请赛现场同步赛 I Matrix Again https://ac.nowcoder.com/acm/contest/700/I 时间限制:C/C++ 1 ...

  9. 2018今日头条杯 E-Jump a Jump

    Problem E. Jump A JumpInput file: standard inputOutput file: standard outputTime limit: 1 secondsMemor ...

随机推荐

  1. centos7 安装VMware tools 出现The path "" is not a valid path to the 3.10.0-514.el7.x86_64 kernel headers

    执行:yum install "kernel-devel-uname-r == $(uname -r)"

  2. 75、python学习第一篇

    1.sys包下边的argv方法,从控制台获取数据 ''' Created on 2017年4月8日 @author: weizhen ''' import sys One = [" * &q ...

  3. 本地安装了flash,前台浏览器还显示需要安装flash?是因为版本需要对应

    NPAPI:适用于FireFox(火狐).Safari(苹果).Opera (欧朋,12.17版以下) PPAPI:适用于Chromium浏览器.Opera (欧朋,15.00版以上) ActiveX ...

  4. Tomcat_startup

    @echo off echo 执行开始时间 date/t time/t echo *********************************************** echo 清除Tomc ...

  5. 【转】理解JMX之介绍和简单使用

    原文链接:https://blog.csdn.net/lmy86263/article/details/71037316 近期在项目上需要添加一些功能,想把一个开源工程整合进来,虽说是整合,但是觉得跟 ...

  6. C# winform 将其他程序嵌入Form窗体

    嵌入类 public class ExeImpaction { public void FrmClosing() { try { if (!process.HasExited) process.Kil ...

  7. webservice的使用-axis1-02

    1.webservice传递javabean 自定义javabean必须是可序列化的 如果javabean中有内部类必须是静态的,因为只有静态的类才可以序列化 如果javabean中用到了其他的jav ...

  8. oracle null+字符串问题

    select 10 + 10 + 10 from dual结果是30,完全没问题. select null + 10 + 10 from dual结果是空串,但期望的结果是20. select nvl ...

  9. LINUX搭建网站环境教程

    安装Mysql yum install mysql-server -y 启动Mysql service mysqld restart 此实验使用 mysql 默认账户名和密码,您也可以设置自己的 My ...

  10. 2018-8-10-win10-UWP-访问网页

    title author date CreateTime categories win10 UWP 访问网页 lindexi 2018-08-10 19:16:51 +0800 2018-2-13 1 ...