1065 A+B and C (64bit) (20分)

PAT上有个错误数据是错的,PAT上说明数据范围是\([-2^{63}, 2^{63}]\),但这个区间里一共有 \(2^{64} + 1\) 个数,已经超出了64bit的范围。

AcWing上将范围限制到了 \([-2^{63}, 2^{63} - 1]\)。

LL a,b,c;
int n;

int main()
{
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cout<<"Case #"<<i<<": ";
        scanf("%lld%lld%lld",&a,&b,&c);
        LL sum=a+b;
        if(a>0 && b>0 && sum<0) //上溢
            cout<<"true"<<endl;
        else if(a<0 && b<0 && sum>=0) //下溢
            cout<<"false"<<endl;
        else if(sum>c)
            cout<<"true"<<endl;
        else
            cout<<"false"<<endl;
    }

    //system("pause");
    return 0;
}
上一篇:1065 A+B and C (64bit) (20 分)


下一篇:[FAQ] golang-migrate/migrate error: migration failed in line 0: (details: Error 1065: Query was emp