poj 1183 数学推导(反正切函数的应用)
来源:互联网 发布:浙江省网络作家 编辑:程序博客网 时间:2024/05/29 12:50
题意:根据角度和的正切函数公式tan(a+b)=[tan(a)+tan(b)]/[1-tan(a)*tan(b)] 公式,通过简单的变换得到: arctan(p)+arctan(q)=arctan[(p+q)/(1-pq)] 公式(4)
如令p=1/2,q=1/3,则(p+q)/(1-pq)=1,有 arctan(1/2)+arctan(1/3)=arctan[(1/2+1/3)/(1-1/2*1/3)]=arctan(1)
我们将上述公式写成如下形式 ,arctan(1/a)=arctan(1/b)+arctan(1/c)
如令p=1/2,q=1/3,则(p+q)/(1-pq)=1,有 arctan(1/2)+arctan(1/3)=arctan[(1/2+1/3)/(1-1/2*1/3)]=arctan(1)
我们将上述公式写成如下形式 ,arctan(1/a)=arctan(1/b)+arctan(1/c)
其中a,b和c均为正整数。 我们的问题是:对于每一个给定的a(1 <= a <= 60000),求b+c的值。我们保证对于任意的a都存在整数解。如果有多个解,要求你给出b+c最小的解。
思路:参考discuss的精彩推导:
1/a = (1/b + 1/c)/ (1 - 1/(b*c))
=> bc-1 = a(b+c)
assume b=a+m and c=a+n (b and c is always bigger than a)
(a+m)(a+n)-1=a(a+m+a+n)
=> a*a+a*n+a*m+m*n-1=2*a*a+m*a+n*a
=> m*n=a*a+1
and then
for(m=a;m>=1;m--)
if((a*a+1)%m==0)
break;
n=(a*a+1)/m
#include <cstdio>#include <cstring>using namespace std;#define clc(s,t) memset(s,t,sizeof(s))#define INF 0x3fffffff#define N 3005int a,b;int main(){ long long a,m,n; scanf("%lld",&a); for(m=a;m>=1;m--) if((a*a+1)%m==0) break; n=(a*a+1)/m; printf("%lld\n",m+n+2*a); return 0;}
0 0
- poj 1183 数学推导(反正切函数的应用)
- poj 1183 反正切函数的应用 数学推导
- POJ 1183---反正切函数的应用【数学问题】
- POJ 1183 反正切函数的应用
- poj-1183 反正切函数的应用
- poj-1183 反正切函数的应用
- poj 1183 反正切函数的应用
- POJ 1183 反正切函数的应用
- POJ 1183 反正切函数的应用
- POJ 1183 反正切函数的应用
- POJ 1183 反正切函数的应用
- POJ 1183 反正切函数的应用
- poj 1183 反正切函数的应用
- (POJ 1183)反正切函数的应用
- POJ 1183 反正切函数的应用(数论)
- POJ 1183 反正切函数的应用(数学代换,基本不等式)
- POJ-1183反正切函数的应用 解题报告(数论) 反正切函数,一个同余问题
- Poj 4227 反正切函数的应用
- 黑马程序员--C语言指针详解
- JDK配置环境变量
- MyEclipse常用操作
- 8.2.1.5 Engine Condition Pushdown Optimization 引擎优化条件推入
- 使用net模块实现基于TCP的数据通信
- poj 1183 数学推导(反正切函数的应用)
- Android欢迎界面的创建方法
- Windows平台使用FFShow录制视频
- android: AAC文件解析
- opencv基础小程序大集合
- 三星Galaxy Tab S2上市,压制苹果之心凸显
- 你知道用AngularJs怎么定义指令吗?
- 备考SharePoint 2010 Certification (70-668)心得
- hdoj 1213 How Many Tables【并查集】