题目:http://acm.hdu.edu.cn/showproblem.php?pid=2552
AC代码(C++):
#include <iostream> #include <queue> #include <string> #include <algorithm> #include <math.h> #define INF 0x3f3f3f3f #define eps 1e-8 using namespace std; int main() { int t; cin >> t; while (t--) { double s, u, v; cin >> s >> u; v = 1.0 / tan(atan(1.0 / s) - atan(1.0 / u)); double ans = v*u - s*u - s*v + eps; printf("%.0lf\n", ans); } //system("pause"); }总结: 水题. 看了网上结题报告, 表达式化简后答案就是1...然而math.h里的tan和atan函数误差都非常大, 所以最后算出来用int取整会大概率WA, 解决方法可以是加上一个大一点的eps或者直接用%.0lf输出.