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 ...
随机推荐
- asp.net mvc-identity初步学习
Install-Package Microsoft.AspNet.Identity.EntityFramework Install-Package Microsoft.AspNet.Identity. ...
- BA-siemens-PXC模块调试
PXC24模块写地址步骤: 1.制作一根HMI线: 2.通过HMI+232转USB转接卡连接模块: 3.根据已经做好的系统架构表来配置模块: 写模块之前不要忘了格式化模块,主要命令如下: 视频教程:h ...
- Spring Boot由jar包转成war包
Spring Boot由jar包转成war包 spring boot 默认是以jar包形式启动web程序,在新建spring boot项目时候可以选择war包的启动方式. 建议在开发的时候建立以jar ...
- poj 3356
Description Let x and y be two strings over some finite alphabet A. We would like to transform x int ...
- (十一)Unity5新特性----实战2D游戏
孙广东 2015.7.11 在本教程中,将了解到U5新功能.你通过本教程.您将了解下面内容: Changes in Component Access Physics Effectors Adding ...
- UVA 294 - Divisors 因子个数
Mathematicians love all sorts of odd properties of numbers. For instance, they consider 945 to be an ...
- angularjs1-4 事件指令
<div ng-app="myApp"> <div ng-controller="firstController"> <div n ...
- UESTC--1269--ZhangYu Speech(模拟)
ZhangYu Speech Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu Submit ...
- MVC 全局异常处理(适用多人操作)
自定义特性: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sy ...
- FluentAPI关系映射配置
都有哪几种关系? 1vs多,多vs多 1. 概念or关系映射相关方法: 1) 基本套路:this.Has***(o=>o.AAA).With***() 当前这个表和AAA属性的表关系是Has定义 ...