poj 1183
题目:http://poj.org/problem?id=1183
前面给了好长的一段描述,最后面的那个公式是关键:arctan(p)+arctan(q)=arctan[(p+q)/(1-pq)],然后题目是给出 a 求 (b + c)满足:arctan(1/a)=arctan(1/b)+arctan(1/c) ,根据掐面的公式可以化简得 : a = (b * c - 1) / (b + c)。令 b = (a + m) c = (a + n)然后代入化简得 m * n = a ^ 2 + 1;所以枚举 m 或 n 然后求出另一个就行了
View Code
1 int main() 2 { 3 int a,b,c; 4 ll i,j; 5 while(~scanf("%d",&a)) 6 { 7 int tem = a; 8 ll kemp = (ll) (a) * (ll) (a) + 1; 9 for(i = tem + 1; i >= 1; i--) 10 { 11 if(kemp % i == 0) 12 { 13 j = kemp / i; 14 break; 15 } 16 } 17 cout<<(2 * tem + i + j)<<endl; 18 } 19 return 0; 20 }