Codeforces Round #415 (Div. 2)C
反正又是一个半小时没做出来。。。
先排序,然后求和,第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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #415 Div. 1
A:考虑每对最大值最小值的贡献即可. #include<iostream> #include<cstdio> #include<cmath> #include< ...
- 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 ...
- 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, ...
- 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 ...
- Codeforces Round #415 (Div. 2) 翻车啦
A. Straight «A» time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #415 (Div. 1) (CDE)
1. CF 809C Find a car 大意: 给定一个$1e9\times 1e9$的矩阵$a$, $a_{i,j}$为它正上方和正左方未出现过的最小数, 每个询问求一个矩形内的和. 可以发现$ ...
随机推荐
- 奇怪的Visual Studio 2013停止响应问题
昨天开始遭遇这个问题,今天再次遭遇. 疑似问题发生在写代码的窗口中复制/粘贴时(有待进一步确认触发条件),突然停止响应,出现下面的对话框: 对话框中的文字为: Waiting for a requir ...
- ubuntu系统下用kazam软件录制的视频不能在windows系统下播放的解决方案
遇到问题: 在做计算机视觉课程作业,运动目标检测与跟踪时,在ubuntu系统下用kazam录制了一小段运动目标检测的视频,然后在课上展示时播放不出来,想着Mp4格式的不应该播放不出来啊.网上寻求了一番 ...
- android中Logcat的TAG过滤
如果代码中有这样的log: Log.e("Foo", "error in foo"); Log.d("Foo", "debug i ...
- 右值引用与转移语义(C++11)
参考资料: http://www.cnblogs.com/lebronjames/p/3614773.html 左值和右值定义: C++( 包括 C) 中所有的表达式和变量要么是左值,要么是右值.通俗 ...
- JDBC连接数据库(二)
原文地址https://blog.csdn.net/jq_ak47/article/details/55049639 Mysql for java 的JDBC 驱动库安装 1.将下载下来的5.1.40 ...
- mac常用操作:
Mac常用软件需要熟悉 常用操作: command + w 关闭窗口 + n 最小化当前窗口 + m 关闭所有窗口 + + w command + c 复制 command + v 粘贴 co ...
- Check out our list of adidas NMD Singapore retailers
The adidas NMD Singapore is confirmed to produce on The month of january 14th at select adidas Origi ...
- 使用Github发布自己的网站
1.编写好自己的index.html 2.在github上新建一个分支,分支名需要按xxx.github.com(xxx为github账号名): 3.进入分支的setting界面,自动生成网页,会在分 ...
- mysql锁机制之综述(一)
https://zhuanlan.zhihu.com/p/29150809 一.数据库有锁机制的原因. 数据库锁定机制简单来说,就是数据库为了保证数据的一致性和有效性,而使各种共享资源在被并发访问变得 ...
- (ZT)谷歌大脑科学家 Caffe缔造者 贾扬清 微信讲座完整版
一.讲座正文:大家好!我是贾扬清,目前在Google Brain,今天有幸受雷鸣师兄邀请来和大家聊聊Caffe.没有太多准备,所以讲的不好的地方还请大家谅解.我用的ppt基本上和我们在CVPR上要做的 ...