2015 Multi-University Training Contest 6 hdu 5358 First One
First One
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 881 Accepted Submission(s): 273
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = ;
LL p[] = {},sum[maxn];
void init() {
for(int i = ; i <= ; ++i)
p[i] = (p[i-]<<);
}
int main() {
init();
int kase,n;
scanf("%d",&kase);
while(kase--){
scanf("%d",&n);
for(int i = ; i <= n; ++i){
scanf("%I64d",sum+i);
sum[i] += sum[i-];
}
LL ret = ;
for(int i = ; i <= && p[i] <= sum[n]; ++i){
int L = ,R = ;
LL tmp = ;
for(int j = ; j <= n; ++j){
while(L <= n && sum[L] - sum[j-] < p[i]) ++L;
while(R + <= n && sum[R + ] - sum[j-] < p[i+]) ++R;
if(L <= R) tmp += (LL)j*(R - L + ) + 1LL*(L + R)*(R - L + )/;
}
ret += tmp*i;
}
for(int i = ; i <= n; ++i)
ret += LL(n + i)*(n - i + )/ + LL(i)*(n - i + );
printf("%I64d\n",ret);
}
return ;
}
2015 Multi-University Training Contest 6 hdu 5358 First One的更多相关文章
- 2015 Multi-University Training Contest 8 hdu 5390 tree
tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...
- 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!
Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: ...
- 2015 Multi-University Training Contest 8 hdu 5385 The path
The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...
- 2015 Multi-University Training Contest 3 hdu 5324 Boring Class
Boring Class Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- 2015 Multi-University Training Contest 3 hdu 5317 RGCDQ
RGCDQ Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submi ...
- 2015 Multi-University Training Contest 10 hdu 5406 CRB and Apple
CRB and Apple Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- 2015 Multi-University Training Contest 10 hdu 5412 CRB and Queries
CRB and Queries Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
- 2015 Multi-University Training Contest 6 hdu 5362 Just A String
Just A String Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2015 Multi-University Training Contest 6 hdu 5357 Easy Sequence
Easy Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
随机推荐
- 关于struts值栈的总结,前端页面如何使用标签取得值栈中的数据
用户提交一次请求的执行过程 总结: struts值栈中 两个内容 一个是栈 一个是map 值栈(数据中心)的范围是一个请求 它代替了request作用域 struts自定义标签有一个特点 比如遍历集合 ...
- Matlab中的函数句柄@
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50699990 @是Matlab中的句柄 ...
- python 中的一些小命令
- BA-siemens-insight使用问题汇总
insight安装完成后不要修改windows时间 1.如果在完成软件安装及授权后,更改了系统的时间,则软件会判断您电脑的时间已经更改,软件将无法启动,所以在软件完成正确安装后,禁止修改系统时间.更改 ...
- 图像算法研究---Adaboost算法具体解释
本篇文章先介绍了提升放法和AdaBoost算法.已经了解的可以直接跳过.后面给出了AdaBoost算法的两个样例.附有详细计算过程. 1.提升方法(来源于统计学习方法) 提升方法是一种经常使用的统计学 ...
- 利用ajax异步处理POST表单中的数据
//防止页面进行跳转 $(document).ready(function(){ $("#submit").click(function(){ var str_data= ...
- Project Euler:Problem 37 Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- MAME 0.201 发布,重温童年的街机模拟器
MAME 0.201 已发布,MAME 最初是街机模拟器,随着时间的推移,MAME 吸收了姊妹项目 MESS(多机种模拟器超级系统),所以 MAME 现在还记录了各种各样的(大多是老式的)电脑游戏.掌 ...
- avformat_find_stream_info函数卡住问题
问题:初始化RTSP流时,在android设备上卡住在avformat_find_stream_info函数,然后程序崩溃. 但其他URL没问题,且同样在代码在iOS上没问题,由于jni调试,也没看到 ...
- Spring《一》
1.支持的注入方式 构建注入,set注入 2.bean属性 id.name.class.singleton(true.false).depends-on="date"(初始化依赖) ...