Use of Function Arctan

 

 Use of Function Arctan

Time Limit:10000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit   Status Description It's easy to know that arctan(1/2)+arctan(1/3)=arctan(1).The problem is,to some fixed number A,you have to write a program to calculate the minimum sum B+C.A,B and C are all positive integers and satisfy the equation below:

arctan(1/A)=arctan(1/B)+arctan(1/C)

Input The first line conta

ins a integer number T.T lines follow,each contains a single integer A, 1<=A<=60000.

Output T lines,each contains a single integer whic

h denotes to the minimum sum B+C.

Sample Input 1 1

 

 1 /*由题意知:B(C-A)=1+AC;B=(1+AC)/(C-A);B=A+(1+AA)/(C-A);C增B减;(易知B=C时B+C最小(此时B=C=a可能为小数,故只需B--枚举即可!!!))*/
 2 
 3 
 4 
 5 
 6 
 7 
 8 #include<stdio.h>
 9 typedef long long LL;
10 int main()
11 {
12     LL B,C,A,i,j,T;
13     scanf("%lld",&T);    
14     for(i=1;i<=T;i++)
15     {
16         scanf("%lld",&A);
17         LL tmp=2*A+2;
18         while((tmp--)>A)
19         if((A*tmp+1)%(tmp-A)==0)
20         {
21             B=(A*tmp+1)/(tmp-A);
22             printf("%lld\n",tmp+B);
23             break;
24         }    
25     }
26 }
View Code

 

 

转载于:https://www.cnblogs.com/skykill/p/3231281.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值