一个暴力的枚举,枚举组成正多边形需要对应覆盖原先的几条边,范围为(1,n/3),然后维护最大值就可以了,注意初始化为-inf.

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int a[];
int main()
{
int n;
while(~scanf("%d",&n)){
int sum=;
for(int i=;i<n;i++){
scanf("%d",&a[i]);
sum+=a[i];
}
int thesum=-;
for(int i=;i<=n/;i++){
if(n%i==){
for(int k=;k<i;k++){
int tempsum=;
for(int j=k;j<n;j+=i){
tempsum+=a[j];
}
if(tempsum>thesum)
thesum=tempsum;
//printf("thesum=%d\n",thesum);
}
}
}
if(thesum>sum)
sum=thesum;
printf("%d\n",sum);
}
}

CodeForces 158DIce Sculptures(枚举)的更多相关文章

  1. codeforces 1183F 离散化枚举 约数定理

    codeforces1183F 有技巧的暴力 传送门:https://codeforces.com/contest/1183/problem/F 题意: 给你n个数,要你从中选出最多三个数,使得三个数 ...

  2. CodeForces 156B Suspects(枚举)

    B. Suspects time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...

  3. CodeForces 379D 暴力 枚举

    D. New Year Letter time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. CodeForces 280B(枚举 + 单调栈应用)

    题目链接 思路如下 这题恶心的枚举任意区间的 最大值及次最大值 ,正常的操作是,是很难实现的,但偏偏有个 单调栈这个动西,能够完成这个任务,跟单调队列相似,有单调 递增.递减的栈,这一题我们需要维护的 ...

  5. Codeforces 1154G(枚举)

    我预处理\(1e7log(1e7)\)的因数被T掉了,就不敢往这个复杂度想了--无奈去看AC代码 结果怎么暴举gcd剪一剪小枝就接近3s卡过去了!vector有锅(确信 const int maxn ...

  6. Codeforces Round #103 (Div. 2) D. Missile Silos(spfa + 枚举边)

    题目链接:http://codeforces.com/problemset/problem/144/D 思路:首先spfa求出中心点S到其余每个顶点的距离,统计各顶点到中心点的距离为L的点,然后就是要 ...

  7. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分

    C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is p ...

  8. Codeforces Round #249 (Div. 2) D. Special Grid 枚举

    题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...

  9. Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举

    题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...

随机推荐

  1. MFC应用程序编写实例—完整版(原创)

    前段时间,将近花了一周至两周上班和上班后的闲余时间,做了一个用于调试和测试工作项目的应用软件,下面将实现软件的重要步骤及主要功能讲解一遍,方便日后查阅. 程序开始后,提示登录框,输入用户名,密码后,登 ...

  2. Git 暂存区的概念

    工作区:我们在电脑里面能看到的目录,也就是我们用git init 命令初始化的那个目录.里面包含要添加文件和需要提交的文件,在这个目录下的文件,修改和变更,我们的git都能感知的到. 版本库:工作区有 ...

  3. QProcess 进程类—调用外部程序

    http://blog.csdn.net/newbee520/article/details/8279101   启动一个新的进程的操作非常简单,只需要将待启动的程序名称和启动参数传递给start() ...

  4. zf-分页后台代码

    java : public ResultPage getDeptList(int page, int pageRows) throws Exception { String hql="fro ...

  5. TextureView+SurfaceTexture+OpenGL ES来播放视频(三)

    引自:http://www.jianshu.com/p/291ff6ddc164 做好的Demo截图 opengl-video 前言 讲了这么多,可能有人要问了,播放视频用个android封装的Vid ...

  6. 安卓常用 widget

    验证码 public class SpinnerImg extends ImageView { /** * 完成选择后启动另外一个spinner */ private ItemListener ite ...

  7. MySQL操作失误导致mysql数据库查看不了

    使用  show databases; +--------------------+| Database           |+--------------------+| information_ ...

  8. ALAssetsLibrary 照片相关 浅析

    ALAssetsLibrary 提供了访问iOS设备下”照片”应用下所有照片和视频的接口: 从 ALAssetsLibrary 中可读取所有的相册数据,即 ALAssetsGroup 对象列表: 从每 ...

  9. AIX创建用户

    -bash-3.2# mkuser test                    创建用户3004-689 User "test" exists.-bash-3.2# finge ...

  10. 简单时钟——css3

    这里我们使用css3的特性制作一个简易的时钟,代码如下: <!DOCTYPE html><html> <head> <meta charset="U ...