BZOJ 1800 [Ahoi2009]fly 飞行棋
来源:互联网 发布:java字符串升序排列 编辑:程序博客网 时间:2024/06/04 08:52
暴力枚举
矩形对角线必定是直径,可以枚举直径,然后算方案数,O(n^2)
也可以直接枚举四个顶点,O(n^4)
#include<cstdio>using namespace std;int sum[23];int main(){ int n; scanf("%d",&n); for(int i = 1; i <= n; i++) { scanf("%d",&sum[i]); sum[i]+=sum[i-1]; } int ans=0; for(int a = 1; a <= n; a++) for(int b = a+1; b <= n; b++) for(int c = b+1; c <= n; c++) for(int d = c+1; d <= n; d++) if(sum[b-1]-sum[a-1]==sum[d-1]-sum[c-1] && sum[c-1]-sum[b-1]==sum[a-1]+sum[n]-sum[d-1]) ans++; printf("%d\n",ans);}
0 0
- bzoj 1800 [Ahoi2009] fly 飞行棋
- BZOJ 1800 AHOI2009 fly 飞行棋 暴力
- BZOJ 1800 [Ahoi2009]fly 飞行棋
- 【BZOJ 1800】[Ahoi2009]fly 飞行棋
- bzoj 1800: [Ahoi2009]fly 飞行棋
- BZOJ 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- 1800: [Ahoi2009]fly 飞行棋
- [Ahoi2009]fly 飞行棋
- 【BZOJ1800】【Ahoi2009】fly 飞行棋
- [BZOJ1800][Ahoi2009]fly飞行棋
- 【AHOI2009】【BZOJ1800】fly 飞行棋
- [BZOJ1800] [Ahoi2009]fly 飞行棋
- BZOJ1800: [Ahoi2009]fly 飞行棋
- bzoj1800: [Ahoi2009]fly 飞行棋
- 让C#可以像Javascript一样操作Json
- The Memory Sinkhole
- redis集群管理
- BUG:android.content.res.Resource$NotFoundException:String resource ID #0X0
- php 限制输入文字
- BZOJ 1800 [Ahoi2009]fly 飞行棋
- 数据库SQL优化大总结
- 32. Longest Valid Parentheses
- Http与HttpClient(已被废弃)通信的介绍,附带一个Http发送GET请求工具类的例子
- Python定时任务框架APScheduler
- linux开放指定端口
- 华为:用一个圈子联接一个圈子
- Xcode 8 新特性
- ACE介绍及简单服务器实例