反正又是一个半小时没做出来。。。

先排序,然后求和,第i个和第j个,f(a)=a[j]-a[i]=a[i]*(2^(j-i-1))因为从j到i之间有j-i-1个数(存在或者不存在有两种情况)

又有a[i+k]-a[i]=a[n]+a[n-1]+...+a[n-k]-a[k+1]-...-a[1]

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=,inf=; ll a[N],sum[N],p[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n;
cin>>n;
p[]=;
for(ll i=;i<=n;i++)
{
p[i]=p[i-]<<;
p[i]%=mod;
}
sum[]=;
for(ll i=;i<=n;i++)cin>>a[i];
sort(a+,a++n);
for(ll i=;i<=n;i++)sum[i]=(sum[i-]+a[i])%mod;
ll ans=;
for(ll i=;i<n-;i++)
{
ans+=(p[i]*(sum[n]+mod-sum[i+]+mod-sum[n-i-])%mod)%mod;
ans%=mod;
}
cout<<ans<<endl;
return ;
} /*
a[i]=sum[n]-sum[n-i-1]-sum[i]
*/

Codeforces Round #415 (Div. 2)C的更多相关文章

  1. Codeforces Round #415 (Div. 2)(A,暴力,B,贪心,排序)

    A. Straight «A» time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  2. Codeforces Round#415 Div.2

    A. Straight «A» 题面 Noora is a student of one famous high school. It's her final year in school - she ...

  3. Codeforces Round #415(Div. 2)-810A.。。。 810B.。。。 810C.。。。不会

    CodeForces - 810A A. Straight «A» time limit per test 1 second memory limit per test 256 megabytes i ...

  4. Codeforces Round #415 Div. 1

    A:考虑每对最大值最小值的贡献即可. #include<iostream> #include<cstdio> #include<cmath> #include< ...

  5. Codeforces Round #415 (Div. 2) A B C 暴力 sort 规律

    A. Straight «A» time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  6. Codeforces Round #415 (Div. 2) C. Do you want a date?

    C. Do you want a date?   2 seconds 256 megabytes   Leha decided to move to a quiet town Vičkopolis, ...

  7. Codeforces Round #415 (Div. 2) B. Summer sell-off

    B. Summer sell-off time limit per test   1 second memory limit per test   256 megabytes   Summer hol ...

  8. Codeforces Round #415 (Div. 2) 翻车啦

    A. Straight «A» time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. Codeforces Round #415 (Div. 1) (CDE)

    1. CF 809C Find a car 大意: 给定一个$1e9\times 1e9$的矩阵$a$, $a_{i,j}$为它正上方和正左方未出现过的最小数, 每个询问求一个矩形内的和. 可以发现$ ...

随机推荐

  1. codeforces#516 Div2---ABCD

    A---Make a triangle! http://codeforces.com/contest/1064/problem/A 题意: 给定三个整数表示三角形的边.每次给边长可以加一,问至少要加多 ...

  2. Prometheus 操作符

    操作符 二元操作符 Prometheus的查询语言支持基本的逻辑运算和算术运算.对于两个瞬时向量, 匹配行为可以被改变. 算术二元运算符 在Prometheus系统中支持下面的二元算术操作符: + 加 ...

  3. Python开发【Django】:ModelForm操作

    ModelForm 内容回顾: Model - 数据库操作 - 验证 class A(MOdel): user = email = pwd = Form class LoginForm(Form): ...

  4. Unity3d GUI适应分辨率

    float sourceWidth = 1024f; float sourceHeight = 768f; float m_fScaleWidth; float m_fScaleHeight; voi ...

  5. java-mybaits-010-mybatis-spring-使用 SqlSession、注入映射器

    一. SqlSession概述 在 MyBatis 中,你可以使用 SqlSessionFactory 来创建 SqlSession.一旦你获得一个 session 之后,你可以使用它来执行映射语句, ...

  6. xmr monero miner

    https://github.com/fireice-uk/xmr-stak-cpu xmr-stak-cpu安装 xmr-stak-cpu是一个用于cpu计算的开源软件,下面记录在ubuntu17. ...

  7. Spark 参数配置的几种方法

    1.Spark 属性Spark应用程序的运行是通过外部参数来控制的,参数的设置正确与否,好与坏会直接影响应用程序的性能,也就影响我们整个集群的性能.参数控制有以下方式:(1)直接设置在SparkCon ...

  8. Spark调优秘诀

    1.诊断内存的消耗 在Spark应用程序中,内存都消耗在哪了? 1.每个Java对象都有一个包含该对象元数据的对象头,其大小是16个Byte.由于在写代码时候,可能会出现这种情况:对象头比对象本身占有 ...

  9. Kconfig文件说明

    Kconfig的格式 下面截取/drivers/net下的Kconfig文件中的部分内容: # Network device configuration menuconfig NETDEVICES d ...

  10. testng生成报告ReportNG美化测试报告

    testng生成报告ReportNG美化测试报告 testng生成报告ReportNG美化测试报告 ReportNG 是一个配合TestNG运行case后自动帮你在test-output文件内生成一个 ...