tjut 4655
来源:互联网 发布:鑫众棋牌源码 编辑:程序博客网 时间:2024/06/08 04:45
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <algorithm> #include <vector> using namespace std; #define maxn 1000010 typedef __int64 LL; vector<LL>v; const LL mod = 1e9+7; LL num[maxn]; LL Pow(LL a,LL b) { LL ans=1; while(b) { if(b&1) { b--; ans=(ans*a)%mod; } else { b/=2; a=(a*a)%mod; } } return ans; } int main() { int t; scanf("%d",&t); while(t--) { v.clear(); int n; scanf("%d",&n); LL S=1; for(int i=1;i<=n;i++) { scanf("%I64d",&num[i]); S=(S*num[i])%mod; } sort(num+1,num+n+1); int l=1,r=n; while(l<=r) { if(l==r) v.push_back(num[l]); else { v.push_back(num[l]); v.push_back(num[r]); } l++; r--; } LL ans=0; for(int i=0;i<n-1;i++) { //cout<<"v["<<i<<"]="<<v[i]<<endl; ans+=S*Pow(max(v[i],v[i+1]),mod-2); ans%=mod; } ans=S*n-ans; ans=(ans%mod+mod)%mod; printf("%I64d\n",ans); } return 0; }
0 0
- tjut 4655
- tjut 4655
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- jQuery动画效果(show与hide/toggle/slideUp/slideToggle/fadeIn/fadeTo)
- 知识点
- HDU1312 BFS-Numerically Speaking
- [LightOJ 1265] Island of Survival (概率)
- 【博弈论】POJ[2348]Euclid's Game
- tjut 4655
- JavaEE程序猿的Java世界观⑤
- 元数据
- 内存分配:堆、栈、全局变量/静态变量、代码区
- PHP 相关知识点
- 456
- Spark on Yarn 图
- monolog文档解读
- centos 7安装jdk1.7等常用开发工具