我正试图从这解决LightOJ问题。我已经对下面的一个进行了编码,但它的答案是错误的。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc;
scanf("%d",&tc);
int dum = 0;
while(tc--)
{
double a,b;
scanf("%Lf : %Lf",&a,&b);
double theta = atan(b/a);
double med = a + theta * sqrt(a*a + b*b);
double rat = 200.0000f/(med);
printf("Case %d: %.8Lf %.8Lf\n",++dum,a*rat,b*rat);
}
return 0;
}但是下面的类似的一个被接受了。
#include <stdio.h>
#include <math.h>
const double PI=acos(-1.0);
int main ()
{
int T,a,b;
scanf("%d",&T);
for (int cas=1;cas<=T;cas++)
{
scanf("%d : %d",&a,&b);
double alpha=atan(1.0*a/b);
double R=200.0/(2.0*sin(alpha)+(PI-2*alpha));
printf("Case %d: %.8lf %.8lf\n",cas,2*R*sin(alpha),2*R*cos(alpha));
}
return 0;
} 我的解决方案做错了什么?
程序说明:我接受两个输入a和b.Where a/b = l/w (l =长度,w=宽度).Then,我在计算角θ。然后,我得到了弧的公式,作为弧+l= 200。我知道比率了。
发布于 2015-09-29 14:16:03
在下一行中使用%Lf是不正确的。
double a,b;
scanf("%Lf : %Lf",&a,&b);%Lf适合于long double,而不是double。使用%lf。
https://stackoverflow.com/questions/32845939
复制相似问题