bzoj2056gift? 高精度?*

bzoj2056gift? 高精度?

题意:

给出abcdefghi,求2^a+2^b+2^c+2^d+2^e+2^f+2^g+2^h+i。a~h≤60,i≤2^63

题解:

发现只有极限数据才会爆unsigned long long,所以先让i-1,然后把它们累加起来,发现这个数据是极限数据就手算出2^64输出字符串,否则就直接+1即可。

注意在算2的n次幂时要1LL<<n,且unsigned long long输出要%llu。

代码:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #define inc(i,j,k) for(int i=j;i<=k;i++)
 5 using namespace std;
 6 
 7 unsigned long long a[10]; int t;
 8 int main(){
 9     scanf("%d",&t);
10     while(t--){
11         inc(i,0,8)scanf("%llu",&a[i]); a[9]=0;
12         if(a[8]==0){
13             inc(i,0,7)a[9]+=(1LL<<a[i]); printf("%llu\n",a[9]);
14         }else{
15             a[8]--; inc(i,0,7)a[9]+=(1LL<<a[i]); a[9]+=a[8];
16             if(a[9]==18446744073709551615)printf("18446744073709551616\n");else printf("%llu\n",a[9]+1);
17         }
18     }
19     return 0;
20 }

 

20160810

转载于:https://www.cnblogs.com/YuanZiming/p/5769466.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值