【BZOJ2056】gift? 高精度?
2056: gift? 高精度?
Time Limit: 10 Sec Memory Limit: 1 MBSubmit: 1302 Solved: 413
[Submit][Status][Discuss]
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
21 30 0 0 0 0 0 0 2147483647
Sample Output
3223322629
【数据规模】
40% t<=1000
100% t<=100000 a,b,c,d,e,f,g,h<=60 i<=9223372036854775808
【数据规模】
40% t<=1000
100% t<=100000 a,b,c,d,e,f,g,h<=60 i<=9223372036854775808
HINT
Source
日常被题目吸引
本来都要写高精了看到了1M内存限制 呵呵
然后我算了一下 ull极限到(2^64)-1 极限数据刚好比这个数大1
特判掉 OK
乱搞能力++

/*To The End Of The Galaxy*/ #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\n"); } else { tmp=1; ans+=(ull)i; rep(1,a,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,b,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,c,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,d,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,e,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,f,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,g,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; rep(1,h,1) { tmp*=(ull)2; } ans+=tmp;tmp=1; printf("%llu\n",ans); } } return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)