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

先排序,然后求和,第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. pta习题集5-16 朋友圈

    某学校有N个学生,形成M个俱乐部.每个俱乐部里的学生有着一定相似的兴趣爱好,形成一个朋友圈.一个学生可以同时属于若干个不同的俱乐部.根据"我的朋友的朋友也是我的朋友"这个推论可以得 ...

  2. 徐州网络赛F-Feature Trace【暴力】

    Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat moveme ...

  3. django-session和cookie

    在Django里面,使用Cookie和Session看起来好像是一样的,使用的方式都是request.COOKIES[XXX]和request.session[XXX],其中XXX是您想要取得的东西的 ...

  4. Day04 dom详解及js事件

    day04 dom详解 DOM的基础 Document对象 Element对象 Node对象 innerHTML 事件处理 表单验证   上次课内容回顾: JS中ECMAScript用法: JS定义变 ...

  5. 省市县三级联动的SQL

    完整版见https://jadyer.github.io/ 首先是建表语句 CREATE TABLE `t_address_province` ( `id` INT AUTO_INCREMENT PR ...

  6. mysql 数据操作 多表查询 准备

    为什么需要多表查询: 因为我们不可能把所有数据都放在一张表里 我们把不同数据存储 放在一张一张不同表 方便管理,但我们为了方便管理,把数据拆分到一张一张表去存储. 但是数据还是一个整体,数据之间是有关 ...

  7. jquery序列化表单以及回调函数的使用

    在开发项目中.将前台的值传给后台,有时的JSP表单中的值有一两个,也有所有的值,假设这时一个个传,必然不是非常好的办法,所以使用jQuery提供的表单序列化方法,能够非常好的解决问题.同一时候能够封装 ...

  8. Swagger2 生成 Spring Boot API 文档

    Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.本文主要介绍了在 Spring Boot 添加 Swagger 支持, 生成可自动维护的 A ...

  9. 整数(质因子)分解(Pollard rho大整数分解)

    整数分解,又称质因子分解.在数学中,整数分解问题是指:给出一个正整数,将其写成几个素数的乘积的形式. (每个合数都可以写成几个质数相乘的形式,这几个质数就都叫做这个合数的质因数.) .试除法(适用于范 ...

  10. STL学习笔记--算法

    关于STL算法需要注意的是: (1) 所有STL算法被设计用来处理一个或多个迭代器区间.第一个区间通常以起点和终点表示,至于其他区间,多数情况下只需提供起点即可,其终点可自动以第一区间的元素数推导出来 ...