一个暴力的枚举,枚举组成正多边形需要对应覆盖原先的几条边,范围为(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. VBS基础篇 - 对象(1) - Class对象

    VBS基础篇 - 对象(1) - Class对象   相信对JAVA有一定了解的朋友一定对类这个名词不陌生,但是大家可能没有想过在VBS中使用Class类吧,其实Class类在自动化测试中是相当常用的 ...

  2. openwrt 包makefile

    $() 表示要执行的一条语句 $(if 条件, 成立执行, 失败执行)        if条件分支 $(foreach 变量, 成员列表, 执行体)   成员遍历语句 可以看出,语句是可以嵌套使用的. ...

  3. Linq第二讲

    这一讲,来说说集合.因为linq主要用于对数据源进行查询,集合是最常见的数据源. 集合 形式: 数组,列表List<T> Arraylist等. 特点: 可通过索引或键访问.可进行fore ...

  4. LeetCode OJ 220.Contains Duplicate 3

    Given an array of integers, find out whether there are two distinct indices i and j in the array suc ...

  5. linux 架设 postfix 邮件服务器

    http://www.cnblogs.com/dudu/archive/2012/12/12/linux-postfix-mailserver.html

  6. R语言笔记5--读数据

    1.读文本文件数据 (1)先设置工作目录,把文本文件放于该目录下 备注:在记事本里写完数据后,按一下回车,负责在R语言中出现错误 (2)读剪贴板 文本或EXCEL的数据均可通过剪贴板操作 (3)读ex ...

  7. 数据库sql语句为什么要用绑定形式?

    基于两点: 1,安全性,防sql注入: 2,共享资源,相似的sql能被缓存而不是重新解析. 淘测试给出了一个很好的理由:http://www.taobaotesting.com/blogs/859

  8. 在Linux中设置共享目录

    1.  是否安装了samba服务 sudo apt-get install samba sudo apt-get install smbfs 2.  创建需要共享的目录/ home/usr/share ...

  9. java使用iText生成pdf表格

    转载地址:http://www.open-open.com/code/view/1424011530749 首先需要你自己下载itext相关的jar包并添加引用,或者在maven中添加如下引用配置: ...

  10. 用 js 做 URL 跳转带来的 Referer 丢失问题.

    http 302 重定向是可以保持 referer 的.例:在 A 页面上提交登录表单到 B,B 返回一个重定向页面到 C,在 C 处理里面检查 Referer 可知道它的来源是 A 而不是 B. 但 ...