SP1440 题解

简要题意

给定 $\arctan(\frac{1}{a})=\arctan(\frac{1}{b})+\arctan(\frac{1}{c})$ 中的 $a$,求 $b+c$ 的最小值。

思路

等式两边同时同取 $\tan$ 值得$$ \frac{1}{a}=\frac{b+c}{b \times c-1} $$ 整理可得$$ \frac{(b \times c-1)}{a}=b+c $$ 令 $y=b+c$,$b=x$,所以$$ y=\frac{(y-x)\times x-1}{a} $$ 整理再求导可得 $y$ 在 $[a+1,2a]$ 区间单调递减,所以从 $2a$ 开始暴力求解即可。

代码

#include <iostream>
#define int long long
using namespace std;
int t, a, n;
signed main(){
    ios::sync_with_stdio(false);
    cin >> t;
    while(t--){
        cin >> n;
        a = n << 1;
        while((a * a + 1) % (a - n))a--;
        cout << (a * a + 1) / (a - n) << endl;
    }
    return 0;
}
posted @ 2023-09-20 11:39  tsqtsqtsq  阅读(5)  评论(0编辑  收藏  举报  来源