期望得分:0+100+100=200

实际得分:0+100+100=200

 

T1 [Ahoi2009]fly 飞行棋

http://www.lydsy.com/JudgeOnline/problem.php?id=1800

利用矩形对角线相等,所以n^2枚举可以凑成对角线的点 

假设有k对

ans=C(k,2)=k*(k-1)/2

#include<cstdio>
using namespace std;
const int maxn = 29;
int N, w[maxn];
int main() 
{
    scanf("%d", &N);
    w[0] = 0;
    for(int i = 1; i <= N; i++)
     {
        scanf("%d", w + i);
        w[i] += w[i - 1];
    }
    if(w[N] & 1) 
    {
        puts("0"); return 0;
    }
    int ans = 0;
    for(int i = 1; i <= N; i++)
        for(int j = i + 1; j <= N; j++)
            if(w[j] - w[i] == (w[N] >> 1)) ans++;
    printf("%d", ans * (ans - 1) >> 1);
    return 0;
}
View Code

相关文章:

  • 2022-01-10
  • 2021-12-06
  • 2021-11-27
  • 2021-11-08
  • 2021-10-11
  • 2022-02-04
  • 2021-08-09
  • 2021-08-22
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-10-24
  • 2021-12-12
  • 2021-10-05
  • 2021-10-02
  • 2021-11-11
相关资源
相似解决方案