BZOJ1800(Ahoi2009)[fly 飛行棋]--幾何

【鏈接】
bzoj1800

【解題報告】

其實只需要算出兩點連線爲圓的直徑的方案數。

答案就是C2ans

#include<cstdio>
using namespace std;
const int maxn=25;
int n,ans,sum,a[maxn];
int main()
{
    freopen("1800.in","r",stdin);
    freopen("1800.out","w",stdout);
    scanf("%d",&n); sum=ans=0;
    for (int i=1; i<=n; i++) scanf("%d",&a[i]),sum+=a[i];
    for (int i=1; i<n; i++)
    {
        int now=a[i];
        for (int j=i+1; j<=n; j++)
        {
            if (sum-now==now) {ans++; break;}
            if (sum-now<now) break;
            now+=a[j];
        }
    }
    printf("%d",ans*(ans-1)/2);
    return 0;
}
發佈了143 篇原創文章 · 獲贊 73 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章