# BZOJ 1800: [Ahoi2009]fly 飞行棋 （尺取+数学）

Posted by 111qqz on Thursday, January 26, 2017

## 1800: [Ahoi2009]fly 飞行棋

Time Limit: 10 Sec  Memory Limit: 64 MB
Submit: 1530  Solved: 1220
[Submit][Status][Discuss]

8
1
2
2
3
1
1
3
3

3

## HINT

N<= 20

``````/* ***********************************************
Author :111qqz
Created Time :2017年01月26日 星期四 18时43分21秒
File Name :code/bzoj/r1800.cpp
************************************************ */

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define fst first
#define sec second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ms(a,x) memset(a,x,sizeof(a))
typedef long long LL;
#define pi pair < int ,int >
#define MP make_pair

using namespace std;
const double eps = 1E-8;
const int dx4[4]={1,0,0,-1};
const int dy4[4]={0,-1,1,0};
const int inf = 0x3f3f3f3f;
const int N=25;
int n,m;
int a[N];
int sum=0;
LL ans=0;
void ruler()
{
int tail;
int cur = 0 ;
head = tail = 1;
{
while (cur>sum) cur-=a[tail++];
if (cur==sum)
{
ans++;
}
}

}
int main()
{
#ifndef  ONLINE_JUDGE
//	freopen("code/in.txt","r",stdin);
#endif

scanf("%d",&n);
for ( int i = 1 ;i  <= n ; i++)
{
scanf("%d",&a[i]);
sum = sum + a[i];
}
//cout<<"sum:"<<sum<<endl;
if (sum%2==1)
{
puts("0");
return 0;
}
sum/=2;
ruler();
//cout<<"sum:"<<sum<<" ans:"<<ans<<endl;
ans=ans*(ans-1)/2;
printf("%lld\n",ans);
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0;
}
``````

「真诚赞赏，手留余香」