CodeForces 158DIce Sculptures(枚举)
一个暴力的枚举,枚举组成正多边形需要对应覆盖原先的几条边,范围为(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(枚举)的更多相关文章
- codeforces 1183F 离散化枚举 约数定理
codeforces1183F 有技巧的暴力 传送门:https://codeforces.com/contest/1183/problem/F 题意: 给你n个数,要你从中选出最多三个数,使得三个数 ...
- CodeForces 156B Suspects(枚举)
B. Suspects time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- CodeForces 379D 暴力 枚举
D. New Year Letter time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 280B(枚举 + 单调栈应用)
题目链接 思路如下 这题恶心的枚举任意区间的 最大值及次最大值 ,正常的操作是,是很难实现的,但偏偏有个 单调栈这个动西,能够完成这个任务,跟单调队列相似,有单调 递增.递减的栈,这一题我们需要维护的 ...
- Codeforces 1154G(枚举)
我预处理\(1e7log(1e7)\)的因数被T掉了,就不敢往这个复杂度想了--无奈去看AC代码 结果怎么暴举gcd剪一剪小枝就接近3s卡过去了!vector有锅(确信 const int maxn ...
- Codeforces Round #103 (Div. 2) D. Missile Silos(spfa + 枚举边)
题目链接:http://codeforces.com/problemset/problem/144/D 思路:首先spfa求出中心点S到其余每个顶点的距离,统计各顶点到中心点的距离为L的点,然后就是要 ...
- 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 ...
- Codeforces Round #249 (Div. 2) D. Special Grid 枚举
题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...
- Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...
随机推荐
- Win7 Cygwin环境试验Nutch tutorial遇到的异常解决方法
安装tutorial的步骤安装Nutch,当执行下面这条命令时出现异常 bin/nutch crawl urls - -topN Injector: starting at -- :: Injecto ...
- Python之路:爬虫之urllib库的基本使用和高级使用
关于爬虫自己一直在看,所以时间太慢,这才第二更,有等不及的小伙伴可以慢慢的品尝了,在看下面的之前,建议先把上一章看一下.以下是关于python的Urllib的基础和高级用法. 1.如何扒下一个网站,用 ...
- servlet第3讲(中集)----同一用户的不同页面共享数据
5.session 5.1session概述 5.2.session应用举例
- implement a system call in minix
http://www.papervisions.com/implementing-system-call-in-minix-os/
- EF6 第一次,或者相隔一段时间变慢咋办? 我们来优化下
第一.问题原因分析 EF方面的原因: 1.Code First第一次启动会对比程序中的Model与数据库表(database initializer ),生成Model与数据库的映射视图 2.随着EF ...
- sqlserver低版本生成插入脚本
--将表数据生成SQL脚本的存储过程 CREATE PROCEDURE dbo.UspOutputData @tablename sysname AS declare @column varchar( ...
- DataBinding
<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http ...
- PHP的反射机制【转载】
PHP5添加了一项新的功能:Reflection.这个功能使得phper可以reverse-engineer class, interface,function,method and extensio ...
- vs找不到svn源代码管理插件之我见
使用svn要安装两个文件,一个客户端:TortoiseSVN-1.8.msi,一个插件:AnkhSvn-2.5.msi:两个都安装好之后,在vs的tool(工具)选项卡中,选择自定义,然后选择sour ...
- 把perl脚本编译成exe
来源:http://www.veryhuo.com/a/view/38338.html 今天想把 perl 脚本编译成 exe 以便脱离 perl 解释器独立运行.都可以生成PERL的PE文件,在PE ...