HDU ACM 2552 三足鼎立

分析:数学公式推到:

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

2.tan( atan(x) ) = x

根据公式1和2有:

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

所以有:uv-us-vs=1。

注意用int取整有误差,不推荐。

#include<iostream>
using namespace std;

int main()
{
	int t;
	double s,u;

	cin>>t;
	while(t--)
	{
		cin>>s>>u;
		puts("1");
	}
    return 0;
}
时间: 2024-08-30 15:45:59

HDU ACM 2552 三足鼎立的相关文章

HDU ACM 1103 Flo&#39;s Restaurant

分析:借助STL的min_element实现.每次更新最先被占用的桌子,具体见注释. #include<iostream> #include<algorithm> using namespace std; int main() { int A,B,C; char s[10]; int a[102],b[102],c[102]; int curtime,count,ans; int *p; //桌子最先空闲时间 while(cin>>A>>B>>C

hdu acm 1425 sort(哈希表思想)

sort Time Limit: 6000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25803    Accepted Submission(s): 7764 Problem Description 给你n个整数,请按从大到小的顺序输出其中前m大的数. Input 每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二行包含n个各不相同,且

HDU ACM 1005 Number Sequence

Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 119732    Accepted Submission(s): 29072 Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A

hdu acm 1166 敌兵布阵 (线段树)

敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 37903    Accepted Submission(s): 15985 Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务

HDU ACM 1025 Constructing Roads In JGShining&amp;#39;s Kingdom-&amp;gt;二分求解LIS+O(NlogN)

#include<iostream> using namespace std; //BFS+优先队列(打印路径) #define N 500005 int c[N]; int dp[N]; //dp[i]保存的是长度为i的最长不降子序列的最小尾元素 int BS(int n,int x) //二分查找下标,当x比全部元素小时下标为1,比全部元素大时下标为n+1. { int low,high,mid; low=1,high=n; while(low<=high) { mid=(low+h

杭电 HDU ACM 圆桌会议

圆桌会议 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3356    Accepted Submission(s): 2351 Problem Description HDU ACM集训队的队员在暑假集训时经常要讨论自己在做题中遇到的问题.每当面临自己解决不了的问题时,他们就会围坐在一张圆形的桌子旁进行交流,经过大家的讨论后一般没有

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker&#39;s Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》

1.2.1 Biker's Trip Odometer #include<stdio.h> #include<math.h> const double PI=acos(-1.0); /* 计算题,根据公式做就行,PI*d*r/(12*5280);res1/t*3600; Sample Input 26 1000 5 27.25 873234 3000 26 0 1000 Sample Output Trip #1: 1.29 928.20 Trip #2: 1179.86 1415

HDU ACM 1098 Ignatius&#39;s puzzle

分析:裴蜀定理,a,b互质的充要条件是存在整数x,y使ax+by=1.存在整数x,y,使得ax+by=c,那么c就是a,b的公约数. 假设存在数a ,因为对任意x方程都成立,则有当x=1时f(x)=18+ka;有因为f(x)能被65整除,所以f(x)=n*65.即18+ka=n*65有整数解则说明假设成立. ax+by = c的方程有整数解的一个充要条件是:c%gcd(a, b) == 0.然后枚举直到(65*n-18)%k == 0. #include<iostream> using nam

HDU ACM 1009 FatMouse&#39; Trade

分析:贪心,每次优先取需要食物的重量和猫食的重量相比最大的,所以先要按比值进行排序,注意J[i]和B[i]要声明为实型,声明为整形就挂了. #include<iostream> #include<algorithm> using namespace std; struct FAT { double f,j; double avg; } fat[1005]; bool cmp(FAT a,FAT b) { if(a.avg<b.avg) return true; else re