codeforces 810C Do you want a date? 数学 快速幂取模
来源:互联网 发布:java get set方法调用 编辑:程序博客网 时间:2024/06/08 10:27
题意:从一个含n个元素 的整数集中,取至少含有两个元素的子集,求所有子集a,,f(a)之和,输出结果为对1e9取模
思路:http://blog.csdn.net/dragon60066/article/details/72599167
#include<cstdio>#include<cstring>#include<algorithm>#define ll long longusing namespace std;const int maxn = 3* (1e5+10);const int mod = 1e9+7;int x[maxn];ll presum[maxn];ll ksm(ll a,ll b){ll base = a;ll ans=1;while(b){if(b&1)ans=(base*ans)%mod;base*=base;base%=mod;b=b>>1;}return ans;}int main(){int n;//freopen("in.txt","r",stdin);while(~scanf("%d",&n)){presum[0]=0;for(int i=1;i<=n;i++){scanf("%d",&x[i]);}sort(x+1,x+n+1);presum[0]=x[n]-x[1];for(int i=1;i<=n-2;i++)presum[i]=presum[i-1]+x[n-i]-x[i+1];ll ans=0;for(int i=0;i<=n-2;i++){//1 3 4ans = (ans+ksm(2,i)*(presum[i]%mod))%mod;}ans%=mod;printf("%I64d\n",ans);}}
阅读全文
0 0
- codeforces 810C Do you want a date? 数学 快速幂取模
- CodeForces 810C Do you want a date? 【数学】【排序】
- Codeforces 810C Do you want a date 枚举
- Codeforces 810C Do you want a date? 题解
- codeforces 810C Do you want a date? 思维
- Codeforces 810C Do you want a date?【思维】
- 810C. Do you want a date?
- Codeforces Round #415 (Div. 2)C. Do you want a date? (数学归纳)
- Codeforces Round #415 (Div. 2) C. Do you want a date? 数学
- Codeforces Round #415 C. Do you want a date?
- codeforces round #415 C.Do you want a Date?
- codeforces——809A/810C——Do you want a date?
- C. Do you want a date?
- 【Codeforces 809 A. Do you want a date?】
- Codeforces 809A Do you want a date?
- CF809A:Do you want a date?(数学 & 思维)
- Codeforces Round #415 (Div. 2)-C. Do you want a date?
- Codeforces Round #415 (Div. 2) C. Do you want a date?
- mysql使用别名作为查询条件的两种方式,必有一种适合你
- C++ Socket编程实例解析
- Http请求方式和报文
- Sublime Text 3 Packages
- python获取代码运行时间
- codeforces 810C Do you want a date? 数学 快速幂取模
- C#中断点不能调试问题(当前不会命中断点,还没有为该文档加载任何资料 )
- HTTP状态码
- DataFrame.loc的区间
- python flask SQLAlchemy 的用法
- 使用Kotlin开发Android应用
- Android反编译
- git 版本控制 回退到某个版本
- Unity 游戏开发实战学习随笔