zoukankan      html  css  js  c++  java
  • JZOJ 1763. Gift

    题目

    Description

     

    Input

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

    Output

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

    Sample Input

    1
    21 30 0 0 0 0 0 0 2147483647
    

    Sample Output

    3223322629
     

    Data Constraint

     
     

    Hint

    【数据规模】
      40% t<=1000
      100% t<=100000 a,b,c,d,e,f,g,h<=60 i<=9223372036854775808

     

    分析

     

    • unsigned long long 开不开高精都可以

     

    代码

     

    #include<cstdio>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    int a,b,c,d,e,f,g,h;
    ull ans;
    ull tmp;
    ull i;
    #define rep(x,y,z) for(int i=(x);i<=(y);i+=(z))
    int main()
    {
        int cas;
        ull com=((ull)9223372036*(ull)1000000000)+(ull)854775808;
        scanf("%d",&cas);
        while(cas--)
        {
            ans=0;
            scanf("%d%d%d%d%d%d%d%d%llu",&a,&b,&c,&d,&e,&f,&g,&h,&i);
            if(a==60&&b==60&&c==60&&d==60&&e==60&&f==60&&g==60&&h==60&&i==com)
                printf("18446744073709551616
    ");
            else
            {
                tmp=1;
                ans+=(ull)i;
                for (int k=1;k<=a;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=b;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=c;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=d;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=e;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=f;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=g;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                for (int k=1;k<=h;k++) tmp*=(ull)2;
                ans+=tmp;tmp=1;
                printf("%llu
    ",ans);
            }
        }
        return 0;
    }
    为何要逼自己长大,去闯不该闯的荒唐
  • 相关阅读:
    jquery 将一组元素转换成数组
    QT5之三大重要窗体
    OSG消息传递机制分析
    OSG消息机制之消息分析
    OSG消息机制之事件处理概述
    OSG 3D场景渲染编程概述
    数据结构之中缀表达式转为后缀
    数据结构之小括号匹配
    考研复习策略
    数据结构之图
  • 原文地址:https://www.cnblogs.com/zjzjzj/p/11158181.html
Copyright © 2011-2022 走看看