Luo Gu 5695 [NOI2001] arc tangent function of the application

topic

Q given each \ (A \) , whether there is a positive integer \ (B, C \) ,
so satisfying \ [\ arctan (\ frac { 1} {a}) = \ arctan (\ frac {1} {b}) + \ arctan ( \ frac {1} {c}) \] so that in the case of \ (b + c \) minimum, and obtains \ (b + c \)


analysis

Because the topics mentioned \ [arctan (P) + arctan (Q) = arctan (\ FRAC {P} + {Q}. 1-PQ) \] , so that the case is to find a \ [\ frac {1} {a} = \ frac {\
frac {1} {b} + \ frac {1} {c}} {1- \ frac {1} {bc}} \] simplifying to give \ (\ frac {1} { a} = \ frac {b +
c} {bc-1} \) , but the key is to \ (b + c \) a \ (a \) and \ (b, c \) are represented by any one,
then consider first represents \ (C \) , then \ [c = \ frac {ab
+ 1} {ba} \] so \ [b + c = b +
\ frac {ab + 1} {ba} \] consideration should \ ( B \) into a key, then \ [B + C = \ {FRAC B ^ 2 + ab & ab &-+. 1} {BA} = \ {FRAC. 1 B ^ 2} + {BA} \]
\ [= \ frac {b ^ 2-a ^ 2 + a ^ 2 + 1} {ba} = b + a + \ frac {a ^ 2 + 1} {ba} = (ba) + \ frac {a ^ 2 + 1} { ba} + 2a (2a is a constant) \]
that \ (y = ax + b / x \) tick function, I can use a junior high school students to be able to make the brain to solve the square root, and \ (a ^ 2 + 1 \) should be(ba \) \ multiples, so the results came out


Code

#include <cstdio>
#define rr register
using namespace std;
int A,a; long long t;
signed main(){
    scanf("%d",&a),A=a;
    for (t=1ll*a*a+1;t%A;++A); A+=a;
    return !printf("%lld",A+(1ll*a*A+1)/(A-a));
}

Guess you like

Origin www.cnblogs.com/Spare-No-Effort/p/12109890.html