codeforces 158D Ice Sculptures (枚举)

系统安装、qt配置、安装pcie驱动 提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 安装Linux系统指定:ununtu20.04并配置相关软件环境 前言 提示:这里可以添加本文要记录的大概内容: ununtu20.04、Qt 5.9.0、pcie驱动 提示:以下是本篇文章正文内容,下面案例可供参考 一、安装系统 制作系统盘(win10),在开机时按相应键进入BIOS,(华硕需要先改配置启动->CSM->开启->第一个选项选第一个或第二个),等待即可 进入后按照https://www.sysgeek. 阅读详情

题目:

D. Ice Sculptures
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they form a regular n-gon. They are numbered in clockwise order with numbers from 1 ton.

The site of the University has already conducted a voting that estimated each sculpture's characteristic of ti — the degree of the sculpture's attractiveness. The values of ti can be positive, negative or zero.

When the university rector came to evaluate the work, he said that this might be not the perfect arrangement. He suggested to melt some of the sculptures so that:

  • the remaining sculptures form a regular polygon (the number of vertices should be between 3 and n),
  • the sum of the ti values of the remaining sculptures is maximized.

Help the Vice Rector to analyze the criticism — find the maximum value of ti sum which can be obtained in this way. It is allowed not to melt any sculptures at all. The sculptures can not be moved.

Input

The first input line contains an integer n (3 ≤ n ≤ 20000) — the initial number of sculptures. The second line contains a sequence of integers t1, t2, ..., tn, ti — the degree of the i-th sculpture's attractiveness ( - 1000 ≤ ti ≤ 1000). The numbers on the line are separated by spaces.

Output

Print the required maximum sum of the sculptures' attractiveness.

Sample test(s)
input
8
1 2 -3 4 -5 5 2 3
output
14
input
6
1 -2 3 -4 5 -6
output
9
input
6
1 2 3 4 5 6
output
21
Note

In the first sample it is best to leave every second sculpture, that is, leave sculptures with attractivenesses: 2, 4, 5 и 3.

题意分析:

很多个雕像围在一起构成一个多边形,每一个占一个点并有个分数。现在需要移除一些雕像,使分数和最大,并且还是能构成多边形。
枚举每次删除的步长l,然后维护一个最大值就好了。枚举步长的上界是l*l<=n。

代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

int a[20005];

int main()
{
    int n,l,ans,temp,i,j;
    while(cin>>n)
    {
        for(int i=0; i<n; i++)
            cin>>a[i];
        ans=-10000000;
        for(int l=1; l*3<=n; l++)//保证至少拥有3个节点
        {
            if(n%l==0)
            {

                for(j=0; j<l; j++)//起始点在第一节步长内
                {
                    temp=0;
                    for(i=j; i<n; i+=l)
                    {
                        temp+=a[i];
                    }
                    ans=max(ans,temp);
                }
            }
        }
        printf("%d\n",ans);
    }
}




openclaw本地模型对接 使用是官方推荐的一种集成方式,它可以简化配置过程。但由于您的系统环境和之前复杂的配置历史,我为您梳理了一个核心流程,并增加了关键的“事后检查”步骤,以确保能从根本上解决问题。 阅读详情

相关推荐

VBA常见错误 - “错误3706,未找到提供程序,该程序可能未正确安装”解决方法

1、问题描述 在利用VBA编程时,引用其它表格数据,出现以下问题: (1)运行“错误3706,未找到提供程序,该程序可能未正确安装”。 (2)引用数据失败 2、解决方法 下载“Access 2010 数据库引擎”,并安装即可。 https://www.microsoft.com/en-us/download/details.aspx?id=54920 AccessDatabaseEngine 2010 官方安装包,官网下载不了的可以来这里下载。(1)运行“错误3706,未找到提..

Nemuel的博客 3万+

D. Ice Sculptures

The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the cam

努力奋斗,为明天,为梦想,无怨无悔 634

嵌入式定点PID控制器:mrm-pid极简实现与实时控制实践

PID控制器是自动控制领域的基础算法,其核心在于比例、积分、微分三环节的协同调节。在资源受限的嵌入式系统中,传统浮点PID易受时序抖动、内存分配不确定性及FPU依赖影响,难以满足毫秒级确定性响应需求。定点PID通过整数运算替代浮点计算,显著提升执行周期稳定性与跨平台兼容性,成为电机控制、传感器补偿等实时场景的关键技术路径。mrm-pid库以位置式结构、int32_t增益参数、int64_t积分累加器和无动态内存设计,实现了超低开销(12–28 CPU周期)与完全可审计的闭环内核,天然适配Cortex-M系列

weixin_31659095的博客 570

codeforces D. Ice Sculptures 题解

本题还是有一定难度的。 注意点: 1 要使用逆向思维,不是要计算melt掉多少sculptures, 而是要计算需要剩下多少个sculptures 2 所有情况都需要考虑到,最大间隔melt掉的sculptures是n/3个 3 要判断这样间隔melt掉sculptures之后,剩下的sculptures是否能组成多边形 要很仔细想清楚才能做出来。 It is never too careful to scrutinize a problem! It is never too careful to desi

靖空间 1404

Badcase归因分析“四部曲”

badcase是业内的专业名词,简单解释一下。bad是坏,case是案例,说白了就是模型或者具体规则无法很好预测的那些案例。以分类模型为例,本来一个样本应该是负类的,结果预测为正类,那这个样本就能被称为bad case。那相对应的就是good case就是优秀案例。

qq_25438419的博客 3517

变焦跟踪理论基础(如何在变焦过程中保持清晰)

如何在整个变焦过程中一直保持图像的清晰度或焦点是变焦跟踪的主要挑战。 当用户在缩放跟踪的情况下改变缩放时,设备保持对焦。 然而,在没有变焦跟踪的情况下,图像变得失焦,图像在变焦跟踪后由于自动对焦(AF)算法才最终对焦。...................................................

ChenYX的博客 20万+

CF 158D Ice Sculptures

D. Ice Sculptures time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The Berland University is preparing to ce

浮生匆忙,与君同往 577

遥感新手别纠结!实测ENVI 5.3、5.6、6.0三个免费版,教你混搭安装避坑

本文为遥感新手提供ENVI 5.3、5.6、6.0三个免费版的实测对比与混搭安装指南,帮助用户构建零成本高效工作流。详细解析各版本功能差异、共存安装技巧及常见问题解决方案,特别适合课程作业、毕业论文分析和遥感入门练习。

weixin_30819085的博客 472

CF158D Ice Sculptures 【睡前水一发。。】

题目链接:http://www.codeforces.com/problemset/problem/158/D TAG:搜索 数学 有N【 VKCUP的一道题。。所以看上去是D其实还是很水。。 枚举N的约数,只有删除某个约数的所有倍数才能使剩下的组成一个正m边形。 然后暴力即可。。【果然很简单么。。】 代码: #include #include #include

ttl_135678942570的专栏 810

图像处理 | 基于matlab的多尺度Retinex(MSR)和自适应直方图均衡化(CLAHE)算法联合的低照度图像增强(附代码)

本文介绍了一种基于多尺度Retinex(MSR)和CLAHE的低照度图像增强算法。算法首先对图像进行多尺度Retinex处理,通过不同尺度的高斯核去除光照影响;然后采用CLAHE算法进行对比度增强。Matlab实现展示了算法流程,包含灰度转换、多尺度Retinex增强和CLAHE处理。实验结果显示,该方法能有效提升低照度图像的可见性,增强细节表现。最后提出了改进建议,包括引入深度学习方法和优化参数选择。

尘世冰封的专栏 952

【Halcon-1D测量】measure_pairs 函数功能(用于提取垂直于矩形/环形弧主轴的直边对)

HALCON算子measure_pairs是1D测量模块的基础工具,专用于提取垂直于矩形/环形弧主轴的直边对。该算子通过振幅阈值和灰度过渡规则(如positive/negative)进行边对分组,支持_strongest后缀选择最强边缘避免误配对。输出包含边缘坐标、振幅及内外间距(IntraDistance/InterDistance)。关键限制包括仅适用于直边、Sigma需≤0.5×测量长度,且忽略图像域。相比模糊版本算子,它更适用于边缘清晰的简单场景(如电子元件间距测量)。典型应用需配合gen_meas

weixin_45590420的博客 303

Codeforces 158 D

题目链接 :http://codeforces.com/contest/158/problem/D D. Ice Sculptures time limit per test 3 seconds memory limit per test 256 megabytes input standard input output stan...

apple201506的博客 189

Android CCodec (十一) Codec2Buffer BufferPool分析

1、序言 2、C2BlockPool分析 3、SimpleC2Component关于BlockingBlockPool的实现 4、总结

给大佬递杯卡布奇诺的博客 4022

[CodeForces158D]Ice Sculptures[暴力]

题目链接:[CodeForces158D]Ice Sculptures[暴力] 题意分析:Berland大学周年庆,有N个冰雕等距地站成一个圈,每个冰雕都有自己的价值,现在你可以融化掉其中的一些,但必须使得剩余的冰雕围城的是正多边形,冰雕不可移动,问:怎么样做可以使得冰雕的价值总和最大,最大是多少? 解题思路:题目给出了3s的时间限制,而冰雕有20000个,可以暴力着对每个答案进行遍历。 个

闲停 860

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Ice Sculptures

 Ice Sculptures time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The Berland University is preparing to

Techay的博客 568

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

codeforces Round#158 Div.2 D

题意: 给出n个点的颜色,和与该点有关边的总权值,让你构造出一棵树,颜色相同的点不能相连,输出所有边和其权值 题解: http://m.blog.youkuaiyun.com/blog/haha593572013/8450520 代码: http://hzwer.com/7257.html

q651111937的专栏 693

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

codeforces 158A Next Round(水题)

A. Next Round 点击打开题目 time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output "Contestant who earns a score equal

1460

codeforces D. Subsequence Hate - 前缀和枚举

codeforces D. Subsequence Hate - 前缀和枚举 题干 Shubham has a binary string s. A binary string is a string containing only characters “0” and “1”. He can perform the following operation on the string any amount of times: Select an index of the string, and flip t

玛软的垃圾桶 259

Codeforces 985B 题解 - 枚举,统计

题意 有\(n\)个开关和\(m\)盏灯,给定一个矩阵\(a(a_{i,j}\in [0,1])\),若\(a_{i,j}=1\)则说明开关\(i\)与第\(j\)盏灯连接.初始时所有灯都是关闭的.按下某开关后,所有与这个开关连接的灯将会打开,已经打开的不会关闭. 现在你需要去掉一个开关,使得按下剩余\(n-1\)个开关后,所有灯都可以打开.若存在方案,则输出YES,否则输出NO. 题解...

230

codeforces 589B (枚举角度题目)

题意: 给定n(n 分析: #include #include #include #include #include #define rep1(i,x,y) for(int i=x;i<=y;i++) #define rep(i,n) for(int i=0;i<(int)n;i++) using namespace std; typedef long long ll; const

playwfun的专栏 683

AtCoder Beginner Contest 158 D - String Formation

直接模拟操作的话肯定会超时,因为每次添加的是一个字符,我们就可以根据翻转次数判断是加在前面还是后面。但是直接用string±还是会超时,换了 insert才过。 AC代码: int m, p; int ans, res, x; int n, q, k; string s, t; int op; int cnt; char c; int main() { cin >> s;...

邵光亮的博客 14万+

codeforces158D

Ice Sculptures CodeForces - 158D The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate...

weixin_30291791的博客 166

Codeforces 540B School Marks 【贪心构造】

Codeforces 540B School Marks 【贪心构造】

世界很大 755

Codeforces 1138B - Circus(构造方程 + 枚举)

题目大意: 给出一个偶数n,接下来输入两个长度为n的01串,在第一个字符串中,1表示编号为 i 的人可以表演小丑,而0表示不可以。在第二个字符串中,1表示编号为 i 的人可以表演杂技,0则表示不可以。一共有两次表演,有以下几条要求: 每个人只能参与一场表演 每次表演的人数必须等于n / 2 第一次表演小丑的人数必须和第二次表演杂技的人数相同 要求找出表演方案,如果能找到,则输出参加第一次表演的演员编号,如果找不到方案则输出 - 1。 解题思路: 假设00 为A, 01 为B 11 为C, 10 为D.

在读NLP硕士 261

codeforces 200 c Football Championship(枚举)

这题真的是有点毒,没说数据范围,我怕数太大分两次去二分,但是二元关系分两次二分还是错了。 然后看了qls代码发现,数据范围其实很小。。那直接枚举check就ok了啊 这一场题的顺序全是乱的,第一次打这样的cf,心累。。 代码: #include using namespace std; struct node { int point; string

johsnows的博客 418

codeforces 351A A. Jeff and Rounding(智商题+枚举)

题目链接:codeforces 351A题目大意:给出2*n个数,n个向上取整,n个向下取整,求新的数的和与原始的数的和的最小差距。题目分析: 机智的人会发现,先对所有的数的小数部分取和,然后如果出现一个向上取整的,那么sum的变化一定是1,所以只和向上取整的数的个数有关系,而向上取整和向下取整的个数已经确定,只有存在小数部分是0的情况的时候,值会不同,因为它转换为向上取整和向下取整的值是不变的。

llin-黎辰 901
上一篇: codeforces 158B Taxi (贪心)
下一篇: Codeforces Round #111 (Div. 2) A Twins (贪心)
Notdeep__acm
博客等级 码龄12年 20粉丝 53原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值