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

题目描述:链接点此

这套题的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. sql存储过程循环实现事务

    //往一张表中添加数据,获取添加数据生成的ID,再往另一张表中添加多条数据 ALTER PROCEDURE [dbo].[AttendanceCardAndDetail_Add] @SchoolID ...

  2. Ruby 技能图谱

    # Ruby 技能图谱 说明: 本图谱只捡重点的列举,并非包含全部.文中所列举或没有列举的资源信息都可以在[awesome-ruby](https://github.com/markets/aweso ...

  3. git 远程库和本地库处理

    创建git库的方法 第一种方法: 在码云建立一个demo的git库.git clone在本地一个文件夹.之后会出现在.git的目录下方(这是clone而非pull切记分清楚) 而不是在.git的上一层 ...

  4. 使用 twine 上传自己的 python 包到 pypi

    打包检查 python setup.py check 打包 python3 setup.py sdist build 上传 twine upload dist/* twine 安装: pip inst ...

  5. SQL 测验题目(30道)

    1.SQL 指的是? 您的回答:Structured Query Language 2.哪个 SQL 语句用于从数据库中提取数据? 您的回答:SELECT 3.哪条 SQL 语句用于更新数据库中的数据 ...

  6. A + B Problem II HDU - 1002

    非常简单的大数加法,因为不会Java只能手写大数加法了;博客存一下以后回来看看 #include<bits/stdc++.h> using namespace std; +; char A ...

  7. qrcode-使用

    安装 composer require endroid/qrcode namespace App\Http\Controllers\Admin; use Endroid\QrCode\QrCode; ...

  8. http常见状态码及其解析

    HTTP状态码常见状态码及其解析 状态码 状态码英文名称 中文描述 100 Continue 继续.客户端应继续其请求 101 Switching Protocols 切换协议.服务器根据客户端的请求 ...

  9. 在apache hadoop2.6 上部署hive 并将hive数据源存储于Mysql

    集成hive 的前提是apache hadoop 集群能够正常启动. hadoop 版本 apach2.6.0  hive 版本:1.2.1 1.安装mysql 并赋予权限: 1.1:创建hive 用 ...

  10. 第一记 搭建Java集成开发环境

    一.JDK JDK可以前往oracle官网进行下载并进行安装(我这边使用的是jdk1.8版本,也推荐使用jdk1.8及以上的) 下图是默认路径安装完成后的截图 安装完成会产生这两个文件夹 二.配置环境 ...