hdu 4655 Cut Pieces
2013-08-10 09:55
337 查看
这个解题报告讲的很详细了!!!
代码如下:
View Code
代码如下:
#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=1; while(b){ if(b&1) ans=(ans*a)%mod; b>>=1; a=(a*a)%mod; } return ans; } int main(){ int t,i,j,n; cin>>t; while(t--){ cin>>n; s=1; for(i=0;i<n;i++){ scanf("%d",&an[i]); s*=an[i]; s%=mod; } sort(an,an+n); j=n-1; ans=n*s%mod; temp=0; for(i=n-1;i>=0;i--){ if(!j) break; ll tt=s*pows(an[i],mod-2)%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 0; }
View Code
相关文章推荐
- hdu 4655 Cut Pieces (找规律)
- hdu 4655 Cut Pieces 找规律
- HDU 4655 Cut Pieces
- HDU 4655 Cut Pieces(2013多校6 1001题 简单数学题)
- HDU-4655 Cut Pieces 数学,贪心
- hdu 4655 Cut Pieces(贪心)
- HDU 4655 Cut Pieces 找规律+简单计数
- hdu 4655——Cut Pieces
- 2013 多校第六场 hdu 4655 Cut Pieces
- HDU 4655 Cut Pieces
- HDU 4655 Cut Pieces(数学分析题)
- HDU 4655 2013多校联合赛第6场 Cut Pieces
- hdu 4655 Cut Pieces(DP 贪心)
- HDU 4655 Cut Pieces
- hdu -4655 Cut Pieces
- hdu 4655 Cut Pieces
- hdu(4655-打表找规律)
- hdu 4655 Cut Pieces/杭电多校第六场1001 找规律,或者dp
- hdu 4655 (组合数)
- hdu 4655 Unshuffle 搜索