三足鼎立

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1818    Accepted Submission(s): 988

Problem Description
MCA山中人才辈出,洞悉外界战火纷纷,山中各路豪杰决定出山拯救百姓于水火,曾以题数扫全场的威士忌,曾经高数九十九的天外来客,曾以一剑铸十年的亦纷菲,歃血为盟,盘踞全国各个要塞(简称全国赛)遇敌杀敌,遇佛杀佛,终于击退辽军,暂时平定外患,三人位置也处于稳态。
可惜辽誓不甘心,辽国征南大将军<耶律javac++>欲找出三人所在逐个击破,现在他发现威士忌的位置s,天外来客的位置u,不过很难探查到亦纷菲v所在何处,只能知道三人满足关系:
arctan(1/s) = arctan(1/u)+arctan(1/v)
注:(其中0 <= x <= 1) 定义 f(s, u, v) = v*u-s*u-s*v 的值 为<三足鼎立>
<耶律javac++>想计算<三足鼎立>的值
 
Input
首先输入一个t,表示有t组数据,跟着t行: 输入s, u (s <= 12^3, u <= 2^20 且 s, u, v > 0) 且s,u,v均为实数
 
Output
输出 v*u-s*u-s*v 的值,为了简单起见,如果是小数,直接取整
比如:答案是1.7 则输出 1
 
Sample Input
1
1 2
 
Sample Output
1
普通做法


 1 #include<stdio.h>
#include<math.h>
int main()
{
int a;
double b,c,s,u,v,t,g;
scanf("%d",&a);
while(a--)
{
scanf("%lf%lf",&b,&c);
s=atan(/b);
u=atan(/c);
v=s-u;
t=tan(v);
t=/t;
g=t*c-b*c-b*t;
printf("%.0lf\n",g);
} return ;
}

二:运用公式做法:

/*1.tan(a+b) = ( tan(a) + tan(b) ) / (1 – tan(a) * tan(b) )

2.tan( atan(x) ) = x

arctan(1/s) = arctan(1/u)+arctan(1/v) 所以得1/s = tan( arctan(1/u)+arctan(1/v) ) = (tan(arctan(1/u)) + tan(arctan(1/v)))/(1-tan(arctan(1/u))*tan(arctan(1/v))) = (1/u + 1/v) / (1 - 1/(uv))

所以解得 uv = 1 + us + vs*/

 #include<stdio.h>
int main()
{
int t,s,u;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&s,&u);
printf("1\n");
}
}

HDU-2552 三足鼎立的更多相关文章

  1. HDOJ/HDU 2552 三足鼎立(tan()和atan()方法)

    Problem Description MCA山中人才辈出,洞悉外界战火纷纷,山中各路豪杰决定出山拯救百姓于水火,曾以题数扫全场的威士忌,曾经高数九十九的天外来客,曾以一剑铸十年的亦纷菲,歃血为盟,盘 ...

  2. HDU 2552 三足鼎立(数学函数)

    /* <耶律javac++>欲找出三人所在逐个击破, 现在他发现威士忌的位置s,天外来客的位置u, 不过很难探查到亦纷菲v所在何处,只能知道三人满足关系: arctan(1/s) = ar ...

  3. 推公式 HDU 2552

    T 给你2个值 求另外一个 需要推一下 tan(a+b)=(tan(a)+tan(b))/(1-tan(a)*tan(b)); 等式左右取tan tan(atan(a))=a 1/s=tan(...) ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  6. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  7. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  8. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  9. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  10. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

随机推荐

  1. leetcode345——Reverse Vowels of a String(C++)

    Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...

  2. 关于C++对汉字拼音的处理(3)

    之所以汉字转拼音的博文能出到3,主要是因为没有很完美的C++的解决方案,但是写到了这里可以有一个小结了. 以前的方法都有这种那种弊端,如果出现了无法识别的汉字(简体的)就无法修改处理了,但是下面的这种 ...

  3. ASP.NET数据绑定控件

    数据绑定控件简介 数据绑定分为:数据源 和 数据绑定控件 两部分,数据绑定控件通过数据源来获得数据,通过数据源来隔离数据提供者和数据使用者,数据源有:SqlDataSource,AccessDataS ...

  4. 远程mysql出现ERROR 1130 (HY000): Host '172.17.42.1' is not allowed to connect to this MySQL server

    ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server 说明所连接的用户帐号没有远程连接的权限, ...

  5. ubuntu下怎么合并windows下分割的zip包

    cat ziptest.z* > google_bak.zip 点击打开链接http://blog.51yip.com/linux/988.html

  6. Nigix快速上手注意事项

    linux下,主要关于配置,包括主从,待续......

  7. window.onresize 多次触发的解决方法

    用了window.onresize但是发现每次 onresize 后页面中状态总是不对,下面与大家分享下onresize 事件多次触发的解决方法. 之前做一个扩展,需要在改变窗口大小的时候保证页面显示 ...

  8. 常见排序算法(PHP实现)

    function InsertSort($arr){ $num = count($arr); for($i = 1; $i < $num; $i++){ $key = $arr[$i]; for ...

  9. Vcl.FileCtrl.SelectDirectory

    描述:显示一个目录的对话框(属于Delphi) function SelectDirectory(var Directory: string; Options: TSelectDirOpts; Hel ...

  10. POJ 3393 Lucky and Good Months by Gregorian Calendar 模拟题

    题目:http://poj.org/problem?id=3393 不多说了,简单模拟题,因为粗心写错了两个字母,导致错了N遍,模拟还是一贯的恶心,代码实在不想优化了,写的难看了点.. #includ ...