閱讀130 返回首頁    go 阿裏雲 go 技術社區[雲棲]


POJ 1183 數學推導

題意:給出arc(tan(1/a))=arc(tan(1/b))+arc(tan(1/c)) 求b+c的最小值。

根據公式 tan(a+b)=(tan(a)+tan(b))/(1-tan(a)*tan(b)) 可以把上式化簡為a=(b*c-1)/(b+c)


補充一句:為什麼不在區間(2a,+oo),因為有一端不確定,同樣的y可能在這個區間會距離2a非常遠,所以超時。

#include <iostream>
#include<cstdio>
using namespace std;

int main()
{
    long long i,a;
    while(~scanf("%lld",&a))
    {
        i=a*2;
        while((i*i+1)%(i-a))i--;
        printf("%lld\n",(i*i+1)/(i-a));
    }
}


最後更新:2017-04-03 16:48:44

  上一篇:go 入門視頻采集與處理(BT656簡介)
  下一篇:go hdu 1556 Color the ball 樹狀數組