这个解题报告讲的很详细了!!!

代码如下:

 #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<vector>
#define ll __int64
#define pi acos(-1.0)
#define MAX 1000010
#define mod 1000000007
using namespace std;
int an[MAX];
ll s,ans,temp;
ll pows(ll a,ll b){
ll ans=;
while(b){
if(b&) ans=(ans*a)%mod;
b>>=;
a=(a*a)%mod;
}
return ans;
}
int main(){
int t,i,j,n;
cin>>t;
while(t--){
cin>>n;
s=;
for(i=;i<n;i++){
scanf("%d",&an[i]);
s*=an[i];
s%=mod;
}
sort(an,an+n);
j=n-;
ans=n*s%mod;
temp=;
for(i=n-;i>=;i--){
if(!j) break;
ll tt=s*pows(an[i],mod-)%mod;
temp=(tt+temp)%mod;
j--;
if(!j) break;
temp=(tt+temp)%mod;
j--;
if(!j) break;
}
printf("%I64d\n",((ans-temp)%mod+mod)%mod);
}
return ;
}

hdu 4655 Cut Pieces的更多相关文章

  1. HDU 4655 Cut Pieces(2013多校6 1001题 简单数学题)

    Cut Pieces Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total ...

  2. hdu 4655 Cut Pieces(想法题)

    Cut Pieces Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  3. HDU 4655 Cut Pieces(数学分析题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4655 题意:给出n个石子,第i个石子可以染ai种颜色.对于每种颜色,比如颜色1221,我们称有3段.连 ...

  4. hdu 4655 Cut Pieces 找规律

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4655 题意:给你一组整数,代表每个木块所能涂成的颜色种数(编号1~ai),相邻的两块所能涂成的颜色如果是一 ...

  5. HDU 4655 Cut Pieces 找规律+简单计数

    解法参考:http://blog.csdn.net/a601025382s/article/details/9840125 #include <cstdio> #include <c ...

  6. HDU 4762 Cut the Cake(公式)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. HDU-4655 Cut Pieces 数学,贪心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4655 先不考虑相临的有影响,那么总数就是n*prod(ai),然后减去每个相邻的对总数的贡献Σ( Mi ...

  8. HDU 4762 Cut the Cake (2013长春网络赛1004题,公式题)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. HDU 4762 Cut the Cake(高精度)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

随机推荐

  1. 第五十八篇、iOS 微信聊天发送小视频的秘密

    对于播放视频,大家应该一开始就想到比较方便快捷使用简单的MPMoviePlayerController类,确实用这个苹果官方为我们包装好了的 API 确实有很多事情都不用我们烦心,我们可以很快的做出一 ...

  2. 相似度到大数据查找之Mysql 文章匹配的一些思路与提高查询速度

    文章相关度匹配的一些思路---"压缩"预料库,即提取用特征词或词频,量化后以“列向量”形式保存到数据库:按前N组词拼为向量组供查询使用,即组合为1到N字的组合,量化后以“行向量”形 ...

  3. javascript 中的 call

    Javascript中call的使用 Javascript中call的使用自己感觉蛮纠结的,根据文档很好理解,其实很难确定你是否真正的理解. call 方法应用于:Function 对象调用一个对象的 ...

  4. Smarty模板引擎技术二

    Smarty模板引擎技术 内建函数 include_php内建函数 作用:载入一个php文件,将载入的文件的内容赋值给一个变量   注意:该内建函数只能在2.0中使用,如果使用的话,必须得实例化Sma ...

  5. 119. Pascal's Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  6. 在20上链接db2

    首先 db2 connect to CICMDB user ptqs using ptqs; db2进入,出现db2 prep cperftest_bysqlc.sqC bindfile; 就可以sq ...

  7. 输入与enter

    #include<iostream> using namespace std; int main() { char a,b,c; while(scanf("%c%c%c" ...

  8. XML节点处理

    XmlDocument xmlDoc = new XmlDocument(); if (!File.Exists(xmlFileName)) { return string.Empty; } xmlD ...

  9. 执行插入语句时直接返回插入信息的自增id,判断是否为空

    insert into userinfo(UserName,UserPass,RegTime,email)values('a','b',GETDATE(),'123@qq.com');select @ ...

  10. input获取永久焦点

    $(function () { $('#test').blur(function () { var that = this; //或者用闭包 setTimeout(function () { $(th ...