三个纯数学计算题,WA了好几次,充分说明我是多么多么马虎!!!!
这三个题都涉及了好多三角函数,我用三角函数都用怕了,怕伤精度T T 。。
水题而已,贴一起吧。
第一个题求外接圆与多边形的面积差,内切圆与多边形的面积差。
第二个是求剩下的体积,那个体积是一个立方体的一半。不过当给的角度比较大的时候,剩余状况是另一种状况了。
第三题,求外接圆,内切圆面积神马的
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define BUG puts("here!!!")
#define STOP system("pause")
using namespace std;
const double pi = acos(-1.0);
int main()
{
int n;
double area;
int ind = 1;
while( ~scanf("%d",&n) && n >= 3 )
{
scanf("%lf", &area);
double ang = 2*pi/n;
double l1 = sqrt(area*2/n/sin(ang));
double a1 = pi*l1*l1;
double l2 = l1*cos(ang/2);
double a2 = pi*l2*l2;
printf("Case %d: %.5lf %.5lf\n",ind++,a1 - area, area - a2);
}
return 0;
}
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define BUG puts("here!!!")
#define STOP system("pause")
using namespace std;
const double pi = acos(-1.0);
int main()
{
double l,w,h,ang;
while( ~scanf("%lf%lf%lf%lf", &l, &w, &h, &ang) )
{
double a1 = atan(h/l);
double ans;
if( ang/180*pi <= a1 )
{
double hh = l * tan(ang/180*pi);
double V = l*w*h;
double v = l*w*hh/2;
ans = V - v;
}
else
ans = h*h*tan(pi/2-ang/180*pi)*w/2;
printf("%.3lf mL\n",ans);
}
return 0;
}
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define BUG puts("here!!!")
#define STOP system("pause")
using namespace std;
const double pi = acos(-1.0);
double area_triangle(double a,double b,double c)
{
double p = (a+b+c)/2.0;
return sqrt(p*(p-a)*(p-b)*(p-c));
}
double circumcir_r(double a,double b,double c)//已知三边求外接圆半径
{
return a*b*c/(4*area_triangle(a,b,c));
}
double incir_r(double a,double b,double c)//已知三边求内切圆半径
{
return 2*area_triangle(a,b,c)/(a+b+c);
}
int main()
{
double a,b,c;
while( ~scanf("%lf%lf%lf", &a, &b, &c) )
{
double r1 = circumcir_r(a,b,c);
double a1 = r1*r1*pi;
double r2 = incir_r(a,b,c);
double a2 = r2*r2*pi;
double a3 = area_triangle(a,b,c);
printf("%.4lf %.4lf %.4lf\n",a1 - a3, a3 - a2, a2);
}
return 0;
}