bz2056

gift? 高精度?

输入格式

输入的第一行为一个整数t。 接下来t行,每行包含九个自然数。

输出格式

输出t行 每行一个整数,表示\(2^a+2^b+2^c+2^d+2^e+2^f+2^g+2^h+i\)

输入数据

1
21 30 0 0 0 0 0 0 2147483647

输出数据

3223322629

数据规模

40% t<=1000 100% t<=100000 a,b,c,d,e,f,g,h<=60 i<=9223372036854775808

题目链接

bz2056

解题思路

可以发现数据最大为 \(2^{64}\),所以不用写高精度,只需特判 \(2^{64}\) 这种情况(而且题目空间限制严格,不允许写高精度~

代码

#include<iostream>
using namespace std;
using ull=unsigned long long;
ull res,x;
short i;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        res=0;
        for(i=0;i<8;i++)
            scanf("%llu",&x),res+=1ull<<x;
        scanf("%llu",&x);
        if(res==1ull<<63&&x==res)
            puts("18446744073709551616");
        else
            printf("%llu\n",res+x);
    }
    return 0;
}
posted @ 2021-08-31 21:01  zyy2001  阅读(41)  评论(0编辑  收藏  举报