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

题目描述:链接点此

这套题的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.

输出描述:

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个小时)

/*
data:2018.04.22
author:gsw
link:https://www.nowcoder.com/acm/contest/104#question
tip:武大校赛--补题
*/
#define IO ios::sync_with_stdio(false);
#define ll long long #include<iostream>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<algorithm> using namespace std; int main()
{
int a,b,c;
while(~scanf("%d%d%d",&a,&b,&c))
{
int ans[];
ans[]=a-;
ans[]=b-;
ans[]=c-;
sort(ans,ans+);
printf("%d %d %d\n",ans[],ans[],ans[]);
}
}

下面会有二分的做法:

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

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

/*
data:2018.04.22
author:gsw
link:https://www.nowcoder.com/acm/contest/104#question
tip:武大校赛--补题
*/
#define IO ios::sync_with_stdio(false);
#define ll long long #include<iostream>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<algorithm>
int a,b,c;
using namespace std; const double expp=1e-;
const double pi=3.14159265358;
const double g3=sqrt()/;
double cosc,x,y,ad,cd,bd,cos_c,th1,th2,mid,ans[];
inline bool judge(double th1)
{
th2=-a-th1;
th1=th1/*pi;th2=th2/*pi;
th1=tan(th1);th2=tan(th2);
x=th2/(th2+th1);
y=x*th1;
//cout<<"x= "<<x<<" "<<y<<endl;
ad=x*x+y*y;
cd=(x-0.5)*(x-0.5)+(y-g3)*(y-g3);
cos_c=(ad+cd-)/(*sqrt(ad*cd));
//cout<<cos_c<<" "<<cosc<<endl;
if(cos_c>cosc)return ;
else return ;
}
inline double ef(double l,double r)
{
while(r-l>expp)
{
mid=(l+r)/;
if(judge(mid))l=mid;
else r=mid;
//cout<<l<<" "<<r<<endl;
}
return l;
}
int main()
{
//freopen("temin.txt","r",stdin);
//freopen("temout.txt","w",stdout); while(~scanf("%d%d%d",&a,&b,&c))
{
cosc=cos((double)c/*pi);
th1=ef(,min(-a,));
th2=-a-th1;
th1=th1/*pi;th2=th2/*pi;
th1=tan(th1);th2=tan(th2);
x=th2/(th2+th1);
y=x*th1;//th2*th1/(th2+th1);
//cout<<x<<" "<<y<<endl;
ad=x*x+y*y;
cd=(x-0.5)*(x-0.5)+(y-g3)*(y-g3);
bd=(x-)*(x-)+y*y;
//cout<<ad<<" "<<cd<<" "<<bd<<endl;
ans[]=acos((ad+cd-bd)/(*sqrt(ad*cd)))/pi*;
ans[]=acos((ad+bd-cd)/(*sqrt(ad*bd)))/pi*;
ans[]=acos((bd+cd-ad)/(*sqrt(bd*cd)))/pi*;
sort(ans,ans+);
printf("%f %f %f\n",ans[],ans[],ans[]);
}
}

再此跟新::

这个优化还是不到位啊,有时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. Spring MVC rest接收json中文格式数据显示乱码

    1.解决方法其中之一 在web.xml下添加配置: <!-- 编码配置 --> <filter> <filter-name>CharacterEncodingFil ...

  2. IDEA2019.1.3最新破解方式

    版本2019.1.3 1.下载破解JAR,放入IDEA的bin文件夹中     链接:https://pan.baidu.com/s/1N1BHeJ0-mmFIWbrh5h4k-g     提取码:g ...

  3. ZROI week3

    作业 poj 1091 跳蚤 容斥原理. 考虑能否跳到旁边就是卡牌的\(gcd\)是否是1,可以根据裴蜀定理证明. 考虑正着做十分的麻烦,所以倒着做,也就是用\(M^N - (不合法)\)即可. 不合 ...

  4. 63、saleforce 的 Merchandise 的简单的增删改查

    自定义的controller public with sharing class MerchandiseController { public List<Merchandise__c> m ...

  5. Python Numpy 矩阵级基本操作(1)

    NumPy的操作介绍 import numpy as np #导入numpy包,简写为np print "Generate 1*10 matrix" a=np.arange(1,1 ...

  6. python学习笔记:python简介和入门

    编程语言各有千秋.C语言适合开发那些追求运行速度.充分发挥硬件性能的程序.而Python是用来编写应用程序的高级编程语言. Python就为我们提供了非常完善的基础代码库,覆盖了网络.文件.GUI.数 ...

  7. 巧妙的使用jmeter来发送json格式数据

    1. header-manager 修改content-type值. 如果不修改该值, 则默认会是urlencode的数据格式(例如a=5&b=6). 修改为json后,会告诉服务器,发送的数 ...

  8. Python运维-获取当前操作系统的各种信息

    #通过Python的psutil模块,获取当前系统的各种信息(比如内存,cpu,磁盘,登录用户等),并将信息进行备份 # coding=utf-8 # 获取系统基本信息 import sys impo ...

  9. Python-02 生成器表达式,列表推导式

    列表推导式和生成器表达式 列表推导式,生成器表达式1,列表推导式比较直观,占内存2,生成器表达式不容易看出内容,省内存. [ 变量(加工后的数据) for  变量i  in 可迭代的数据类型 ] 列表 ...

  10. 12-python基础—python3中的reduce()

    在 Python3 中,reduce() 函数已经被从全局名字空间里移除了,它现在被放置在 functools 模块里,需要通过引入 functools 模块来调用 reduce() 函数: from ...