July 17th 模拟赛C T1 Gift Solution

来源:互联网 发布:万能摄像头软件下载 编辑:程序博客网 时间:2024/05/29 06:51

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

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
原创粉丝点击