hdu5358 First One】的更多相关文章

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud First One Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1158    Accepted Submission(s): 347 Problem Description soda has an integer…
尺取+枚举,推出公式以后就是一个枚举加尺取 但是这题的尺取不是对一个值尺取,而是在一个区间内,所以固定左边界,尺取右边界即可 #include<bits/stdc++.h> #define maxn 100005 #define ll long long using namespace std; int t,n,m,k,x,y,z,l,tot; ll cnt,sum[maxn]; int a[maxn]; ll solve(ll L,ll R){//求区间[l,R)内i+j的和 ll ans=…
题目链接: First One Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others) Problem Description   soda has an integer array a1,a2,…,an. Let S(i,j) be the sum of ai,ai+1,…,aj. Now soda wants to know the value below: ∑i=1n∑j=…
题意:直接来链接吧http://acm.hdu.edu.cn/showproblem.php?pid=5358 思路:注意S(i,j)具有区间连续性且单调,而⌊log2x⌋具有区间不变性,于是考虑枚举⌊log2S(i,j)⌋的值,然后枚举i,从而能得到j的区间范围,然后统计答案即可. 另外这题比较坑,先枚举 ⌊log2S(i,j)⌋再枚举i 老是TLE,加了各种常数优化还是TLE,换成先枚举i再枚举⌊log2S(i,j)⌋就过了. 1 2 3 4 5 6 7 8 9 10 11 12 13 14…
Problem Description soda has an integer array a1,a2,-,an. Let S(i,j) be the sum of ai,ai+1,-,aj. Now soda wants to know the value below: ∑i=1n∑j=in(⌊log2S(i,j)⌋+1)×(i+j) Note: In this problem, you can consider log20 as 0.   Input There are multiple t…