https://ac.nowcoder.com/acm/contest/881/F
打表代码:
#include<bits/stdc++.h> using namespace std; double x[3]= {0,1,0},y[3]= {0,0,1}; double a,b; double area(double x1,double y1,double x2,double y2,double x3,double y3) { return fabs(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2); } double cal() { double t=area(a,b,x[1],y[1],x[2],y[2]); t=max(t,area(a,b,x[0],y[0],x[1],y[1])); t=max(t,area(a,b,x[0],y[0],x[2],y[2])); return t; } int main() { //double a,b; int R=100; while(R--) { srand(time(NULL)); double ans=0,t; int f=0; for(int i=1; i<=10000; i++) { f=rand()%2; a=rand()%1001/1001.0; b=rand()%1001/1001.0; t=a+b; if(t>1){ a=a/t; b=b/t; } //cout<<a<<b<<' '; ans+=cal(); } cout<<36*ans/10000<<' '; } }
AC代码:
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll x[3],y[3]; int main() { while(scanf("%lld%lld%lld%lld%lld%lld",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2])!=EOF){ ll s=abs(x[1]*y[2]+x[2]*y[0]+x[0]*y[1]-x[0]*y[2]-x[1]*y[0]-x[2]*y[1]); // cout<<s<<endl; cout<<11*s<<' '; } }