July 17th 模拟赛C T1 Gift Solution

空降题目处(外网)
点我点我点我

空降题目处(内网)
点我点我点我

Description

(WHAT THE F**K)

Input

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

Output

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

Solution

Some People Said That We Need High-Precision?!
有些人说要高精度?
Qword(Unsigned Long Long) Can Solve It,Just Need Pretreatment.
Qword(Unsigned Long Long)就能解决,只需要预处理(打表)

Code

C++

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

unsigned long long x,y,m[61];
int t;
bool p;

int main()
{
    m[0]=1LL;
    for (int i=1;i<=60;i++)
        m[i]=m[i-1]*2;
    scanf("%d",&t);
    for (int i=1;i<=t;i++)
    {
        x=0;
        p=true;
        for (int j=1;j<=8;j++)
        {
            scanf("%llu",&y);
            x+=m[y];
            if (y!=60LL)
                p=false;
        }
        scanf("%llu",&y);
        if ((p)&&(y==9223372036854775808LL))
            printf("18446744073709551616\n");
        else
            printf("%llu\n",x+y);
    }
}

Pascal

var
    x,y:qword;
    t,i,j:longint;
    p:boolean;
    m:array [0..60] of qword;

begin

    m[0]:=1;
    for i:=1 to 60 do
        m[i]:=m[i-1]*2;
    readln(t);
    for i:=1 to t do
    begin
        x:=0;
        p:=true;
        for j:=1 to 8 do
        begin
            read(y);
            x:=x+m[y];
            p:=(p) and (y=60);
        end;
        read(y);
        if (p) and (y=9223372036854775808) then
            writeln('18446744073709551616')
        else
            writeln(x+y);
    end;

end.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值