BZOJ 2056 gift? 高精度?

Posted on 2016-10-12 17:11  ziliuziliu  阅读(94)  评论(0编辑  收藏  举报

只有极限情况会爆unsigned long long

#include<cstdio>
using namespace std;
int t,x;
unsigned long long ans,y;
int main()
{
    scanf("%d",&t);
    for (int i=1;i<=t;i++)
    {
        ans=0;
        for (int j=1;j<=8;j++)
        {
            scanf("%d",&x);
            ans+=(1LL<<x);
        }
        scanf("%llu",&y);
        if ((ans==(1LL<<63)) && (y==ans)) printf("18446744073709551616\n");
        else printf("%llu\n",ans+y);    
    }
    return 0;
}