Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:公式我找到了(程序也AC了)~可是意思还是不太理解,能提点一下在哪找到的公式,或者思路是怎样的吗?In Reply To:Re:公式我找到了(程序也AC了)~可是意思还是不太理解,能提点一下在哪找到的公式,或者思路是怎样的吗? Posted by:ray58750034 at 2005-03-05 23:28:08 qsort(a, n, sizeof(long long), compare); for(i=0;i<n-1;i++) vol+=(a[i+1]-a[i])*(i+1)*(n-i-1); cout<<vol*2; 从左向右传和从右向左传是对称的, 所以vol×2; 考虑中间的一小段距离,因为左边的牛的声音 要传到右边的牛的耳朵里,必然要经过一些相邻的小段距离, 这些距离是要被重复计算的,而某一段左边有i+1头牛, 右边有n-i-1头牛,所以是(i+1)×(n-i-1) Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator