这个模板是别人的由于支持负数操作就搬过来用了QAQ
模板原地址:http://www.cnblogs.com/huanglianjing/p/4002872.html
这道题裸的求外接圆圆心和半径,只要判断第四个点到圆心的距离比半径大就好了
注意:计算几何如果都是整数点,距离什么的都不要开方,除法都不除,别的地方乘上去,保证没有误差,1次就AC
AC代码:
//大数模板,以青岛1001为例
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <iostream>
using namespace std;
#define MAXBIT 1007
#define BITTYPE int
typedef long long ll;
class BigInt
{
public:
BITTYPE bit[MAXBIT];
bool negative;
public:
BigInt(); //默认构造函数,值为0
BigInt(const ll); //构造函数
BigInt(const char *); //构造函数
BigInt(const BigInt &); //复制构造函数
/*重载赋值运算符*/
BigInt& operator=(const BigInt&);
BigInt& operator=(const int );
/*重载算数运算符*/
BigInt operator+(const BigInt& )const;
BigInt operator+(const int )const;
BigInt operator+=(const BigInt& );
BigInt operator+=(const int );
BigInt operator-(const BigInt& )const;
BigInt operator-(const int )const;
BigInt operator-=(const BigInt& );
BigInt operator-=(const int );
BigInt operator-( )const;
BigInt operator*(const BigInt& )const;
BigInt operator*(const int )const;
BigInt operator*=(const BigInt& );
BigInt operator*=(const int );
BigInt operator/(const int )const;
BigInt operator/=(const int );
int operator%(const int )const;
BigInt operator%=(const int );
/*重载比较运算符*/
bool operator>(const BigInt& )const;
bool operator>(const int )const;
bool operator>=(const BigInt& )const;
bool operator>=(const int )const;
bool operator<(const BigInt& )const;
bool operator<(const int )const;
bool operator<=(const BigInt& )const;
bool operator<=(const int )const;
bool operator==(const BigInt& )const;
bool operator==(const int )const;
bool operator!=(const BigInt& )const;
bool operator!=(const int )const;
void print() const;//输出数值
char *string() const;//返回数值字符串
bool isZero() const;//是否为0
bool isPositive() const;//是否为正数
bool isNegative() const;//是否为负数
bool nonNegative() const;//是否为非负数
private:
BigInt opposite()const;//取相反数
BigInt absoluteAdd(const BigInt&)const;//加上绝对值
BigInt absoluteMinus(const BigInt&)const;//减去绝对值小于自身的数的绝对值
bool absoluteEqual(const BigInt&)const;//绝对值等于
bool absoluteGreater(const BigInt&)const;//绝对值大于
bool absoluteEqualGreater(const BigInt&)const;//绝对值大于等于
};
BigInt::BigInt()
{
memset(bit,0,sizeof(bit));
negative = false;
}
BigInt::BigInt(const ll n)
{
memset(bit,0,sizeof(bit));
ll nn = n;
if (nn>=0) negative = false;
else
{
negative = true;
nn = -nn;
}
ll pos = 0;
while (nn)
{
bit[pos++] = nn % 10;
nn /= 10;
}
}
BigInt::BigInt(const char *s)
{
int len = strlen(s);
bool valid = true;//符合数字格式
if (len >= 2)
{
if (s[0]!='+' && s[0]!='-' && !isdigit(s[0])) valid = false;
for (int i=1; i<len; ++i)
{
if (!isdigit(s[i])) valid = false;
}
}
else if (len == 1)
{
if (!isdigit(s[0])) valid = false;
}
if (len==0 || !valid)
{
memset(bit,0,sizeof(bit));
negative = false;
return;
}
int beg = 0, end = len-1;
if (s[0] == '+')
{
negative = false;
++beg;
}
else if (s[0] == '-')
{
bool zeroFlag = true;
for (int i=1; i<len; ++i)
{
if (s[i]!='0')
{
zeroFlag = false;
break;
}
}
if (zeroFlag) negative = false;
else negative = true;
++beg;
}
else negative = false;
memset(bit,0,sizeof(bit));
for (int i=beg; i<=end; ++i)
{
bit[len-1-i] = s[i] - '0';
}
}
BigInt::BigInt(const BigInt& n)
{
memcpy(bit,n.bit,sizeof(bit));
negative = n.negative;
}
BigInt& BigInt::operator=(const BigInt& n)
{
memcpy(bit,n.bit,sizeof(bit));
negative = n.negative;
return *this;
}
BigInt& BigInt::operator=(const int n)
{
return *this = BigInt(n);
}
BigInt BigInt::operator+(const BigInt& n)const
{
if ((!negative && !n.negative) || (negative && n.negative))
{
return this->absoluteAdd(n);
}
else
{
if (absoluteEqual(n)) return BigInt();
else if (absoluteEqualGreater(n)) return this->absoluteMinus(n);
else return n.absoluteMinus(*this);
}
}
BigInt BigInt::operator+(const int n)const
{
return *this + BigInt(n);
}
BigInt BigInt::operator+=(const BigInt& n)
{
return *this = *this + n;
}
BigInt BigInt::operator+=(const int n)
{
return *this = *this + n;
}
BigInt BigInt::operator-(const BigInt& n)const
{
return *this + n.opposite();
}
BigInt BigInt::operator-(const int n)const
{
return *this - BigInt(n);
}
BigInt BigInt::operator-=(const BigInt& n)
{
return *this = *this - n;
}
BigInt BigInt::operator-=(const int n)
{
return *this = *this - n;
}
BigInt BigInt::operator-()const
{
BigInt bi(*this);
if (!this->isZero()) bi.negative = !bi.negative;
return bi;
}
BigInt BigInt::operator*(const BigInt& n)const
{
if (isZero() || n.isZero()) return BigInt();
BigInt bi = BigInt();
if ((!negative && !n.negative) || (negative && n.negative))
{
bi.negative = false;
}
else bi.negative = true;
for (int i=0; i<MAXBIT; ++i) for (int j=0; j<MAXBIT-i; ++j)
{
bi.bit[i+j] += bit[i] * n.bit[j];
}
for (int i=0; i<MAXBIT-1; ++i) //进位
{
bi.bit[i+1] += bi.bit[i] / 10;
bi.bit[i] %= 10;
}
return bi;
}
BigInt BigInt::operator*(const int n)const
{
return *this * BigInt(n);
}
BigInt BigInt::operator*=(const BigInt& n)
{
return *this = *this - n;
}
BigInt BigInt::operator*=(const int n)
{
return *this = *this * n;
}
BigInt BigInt::operator/(const int n)const
{
//除以0直接返回0
if (isZero() || n==0) return BigInt();
BigInt bi = BigInt();
if ((!negative && n>0) || (negative && n<0))
{
bi.negative = false;
}
else bi.negative = true;
int div = 0;//累计除数
for (int i=MAXBIT-1; i>=0; --i)
{
div = div * 10 + bit[i];
bi.bit[i] = div / n;
div %= n;
}
return bi;
}
BigInt BigInt::operator/=(const int n)
{
//除以0直接返回0
if (isZero() || n==0) return BigInt();
else return *this = *this / n;
}
int BigInt::operator%(const int n)const
{
int mod = 0;//累计余数
for (int i=MAXBIT-1; i>=0; --i)
{
//mod = ((mod*(MAXBIT+1/*??*/)) + bit[i]) % n;
mod = ((mod*10) + bit[i]) % n;
}
return mod;
}
BigInt BigInt::operator%=(const int n)
{
int mod = 0;//累计余数
for (int i=MAXBIT-1; i>=0; --i)
{
//mod = ((mod*(MAXBIT+1/*??*/)) + bit[i]) % n;
mod = ((mod*10) + bit[i]) % n;
}
return *this = BigInt(mod);
}
bool BigInt::operator>(const BigInt& n)const
{
if (!negative && n.negative) return true;
else if (negative && !n.negative) return false;
else if (!negative && !n.negative) return absoluteGreater(n);
else return n.absoluteGreater(*this);
}
bool BigInt::operator>(const int n)const
{
return *this > BigInt(n);
}
bool BigInt::operator>=(const BigInt& n)const
{
if (!negative && n.negative) return true;
else if (negative && !n.negative) return false;
else if (!negative && !n.negative) return absoluteEqualGreater(n);
else return n.absoluteEqualGreater(*this);
}
bool BigInt::operator>=(const int n)const
{
return *this >= BigInt(n);
}
bool BigInt::operator<(const BigInt& n)const
{
return n > *this;
}
bool BigInt::operator<(const int n)const
{
return *this < BigInt(n);
}
bool BigInt::operator<=(const BigInt& n)const
{
return n >= *this;
}
bool BigInt::operator<=(const int n)const
{
return *this <= BigInt(n);
}
bool BigInt::operator==(const BigInt& n)const
{
if (negative != n.negative) return false;
for (int i=0; i<MAXBIT; ++i)
{
if (bit[i] != n.bit[i]) return false;
}
return true;
}
bool BigInt::operator==(const int n)const
{
return *this == BigInt(n);
}
bool BigInt::operator!=(const BigInt& n)const
{
if (negative != n.negative) return true;
for (int i=0; i<MAXBIT; ++i)
{
if (bit[i] != n.bit[i]) return true;
}
return false;
}
bool BigInt::operator!=(const int n)const
{
return *this != BigInt(n);
}
void BigInt::print()const
{
if (negative) printf("-");
int pos = MAXBIT - 1;
for (; pos>0; --pos)
{
if (bit[pos]) break;
}
for (int i=pos; i>=0; --i) printf("%d",bit[i]);
}
char *BigInt::string()const
{
char content1[1007+2];
int posi = 0;
if (negative) content1[posi++] = '-';
int pos = MAXBIT - 1;
for (; pos>0; --pos)
{
if (bit[pos]) break;
}
//printf("pos = %d\n",pos);
for (int i=pos; i>=0; --i)
{
content1[posi++] = bit[i] + '0';
//printf("bit[%d] = %d\n",i,bit[i]);
}
content1[posi] = '\0';
return content1;
}
bool BigInt::isZero()const
{
bool zeroFlag = true;
for (int i=0; i<MAXBIT; ++i)
{
if (bit[i] != 0)
{
zeroFlag = false;
break;
}
}
return zeroFlag;
}
bool BigInt::isPositive()const
{
return !negative && !isZero();
}
bool BigInt::isNegative()const
{
return negative;
}
bool BigInt::nonNegative()const
{
return !negative;
}
BigInt BigInt::opposite()const
{
BigInt n(*this);
if (!n.isZero()) n.negative = !n.negative;
return n;
}
BigInt BigInt::absoluteAdd(const BigInt& n)const
{
BigInt bi(*this);
int next = 0;//进位
for (int i=0; i<MAXBIT; ++i)
{
bi.bit[i] = (bit[i] + n.bit[i] + next) % 10;
next = (bit[i] + n.bit[i] + next) / 10;
}
return bi;
}
BigInt BigInt::absoluteMinus(const BigInt& n)const
{
BigInt bi(*this);
for (int i=MAXBIT-1; i>=0; --i)
{
if (bi.bit[i]>=n.bit[i]) bi.bit[i] -= n.bit[i];
else //借位
{
int borrow = i + 1;//借位位
while (bi.bit[borrow]==0) ++borrow;
--bi.bit[borrow];
for (int j=i+1; j<borrow; ++j) bi.bit[j] = 9;
bi.bit[i] = bi.bit[i] + 10 - n.bit[i];
}
}
return bi;
}
bool BigInt::absoluteEqual(const BigInt& n)const
{
for (int i=0; i<MAXBIT; ++i)
{
if (bit[i] != n.bit[i]) return false;
}
return true;
}
bool BigInt::absoluteGreater(const BigInt& n)const
{
for (int i=MAXBIT-1; i>=0; --i)
{
if (bit[i]>n.bit[i]) return true;
else if (bit[i]<n.bit[i]) return false;
}
return false;
}
bool BigInt::absoluteEqualGreater(const BigInt& n)const
{
for (int i=MAXBIT-1; i>=0; --i)
{
if (bit[i]>n.bit[i]) return true;
else if (bit[i]<n.bit[i]) return false;
}
return true;
}
BigInt dist(BigInt px1,BigInt py1,BigInt px2,BigInt py2)
{
BigInt t;
t=(px1-px2)*(px1-px2)+(py1-py2)*(py1-py2);
return t;
}
BigInt coco(BigInt px1,BigInt py1,BigInt px2,BigInt py2,BigInt px3,BigInt py3,BigInt &qx,BigInt &qy,BigInt &d)
{
BigInt r;
BigInt er(2);
BigInt x12=px2-px1;
BigInt y12=py2-py1;
BigInt x13=px3-px1;
BigInt y13=py3-py1;
BigInt z2=x12*(px1+px2)+y12*(py1+py2);
BigInt z3=x13*(px1+px3)+y13*(py1+py3);
d=er*((x12*py3+y12*px2)-(y12*px3+x12*py2));
qx=y13*z2-y12*z3;
qy=x12*z3-x13*z2;
r=dist(d*px1,d*py1,qx,qy);
return r;
}
int main()
{
int T;
cin>>T;
while(T--)
{
ll a1,b1,c1,d1,e1,f1,g1,h1;
cin>>a1>>b1>>c1>>d1>>e1>>f1>>g1>>h1;
BigInt px1(a1);
BigInt py1(b1);
BigInt px2(c1);
BigInt py2(d1);
BigInt px3(e1);
BigInt py3(f1);
BigInt px4(g1);
BigInt py4(h1);
BigInt qx;
BigInt qy;
BigInt d;
BigInt r=coco(px1,py1,px2,py2,px3,py3,qx,qy,d);
BigInt tem=dist(qx,qy,d*px4,d*py4);
if(tem>r)
printf("Accepted\n");
else
printf("Rejected\n");
}
}