题意:
给定一个圆弧边矩形,长a宽b,周长为400,且两边的圆弧同属一个圆。给出长宽比m:n,求长和宽
策略:列方程求解。
令k=n/m,则解出a = 200 / (1 + atan(k)*sqrt(1+k*k));
代码:
#include#include using namespace std;int main(){// freopen("in.txt", "r", stdin); int m, n; int id = 1; while(scanf("%d : %d", &m, &n)!=EOF){ double k = n*1.0/m; double a = 200/(1+atan(k)*sqrt(1+k*k)); double b = a*k; printf("Case %d: %.10lf %.10lf\n", id++, a, b); } return 0;}