题目链接:Roman and Browser

题目原文

This morning, Roman woke up and opened the browser with ? opened tabs numbered from 1 to ?. There are two kinds of tabs: those with the information required for the test and those with social network sites. Roman decided that there are too many tabs open so he wants to close some of them.

He decided to accomplish this by closing every ?-th (2≤?≤?−1) tab. Only then he will decide whether he wants to study for the test or to chat on the social networks. Formally, Roman will choose one tab (let its number be ?b) and then close all tabs with numbers ?=?+?⋅? that satisfy the following condition: 1≤?≤?1≤c≤n and ?s an integer (it may be positive, negative or zero).

For example, if ?=3, ?=14 and Roman chooses ?=8, then he will close tabs with numbers 2,  5, 8, 11 and 14.

After closing the tabs Roman will calculate the amount of remaining tabs with the information for the test (let's denote it ?) and the amount of remaining social network tabs (?). Help Roman to calculate the maximal absolute value of the difference of those values |?−?| so that it would be easy to decide what to do next.

题目大意

浏览器有标号为1-n的n个两种标签页,选择其中的一个标签页,以间隔b(b是不确定的)等间隔的关闭相应的标签页。求最后两种标签页数量的差值。

思路

按照公式?=?+?⋅?,删除所有位置为c的元素,求剩余元素的绝对值的最大值。数据范围很小,暴力过一遍就行。

题解

 1 #include <iostream>
 2 #include <cstring>
 3
 4 using namespace std;
 5
 6 int n, k, ans;
 7 int a[105];
 8
 9 int main(int argc, char const *argv[])
10 {
11     cin >> n >> k;
12     int tmp = 0;
13     for (int i = 0; i < n; i++)
14     {
15         cin >> a[i];
16     }
17     for (int b = 0; b < k; b++)
18     {
19         tmp = 0;
20         for (int i = 0; i < n; ++i)
21         {
22             if ( i-b>=0 && (i-b) % k == 0)
23             {
24
25             }else{
26                 tmp += a[i];
27             }
28         }
29         if (tmp < 0)
30         {
31             tmp = -tmp;
32         }
33         if(tmp > ans)
34         {
35             ans = tmp;
36         }
37     }
38
39     cout << ans;
40     return 0;
41 }

转载于:https://www.cnblogs.com/SaltyFishQF/p/10392847.html

Roman and Browser-罗曼的浏览器 CodeForce1100A 暴力相关推荐

  1. opencv 罗曼滤波_勒罗曼杜罗伊

    opencv 罗曼滤波 9之第5部分/ Moritz Kleinsorge的企业字体 (Part 5 of 9 / Corporate Typefaces by Moritz Kleinsorge) ...

  2. 网红咖啡店的最后一晚:五道口的罗曼蒂克如何消亡

    中新网客户端北京1月15日电 题:五道口罗曼蒂克消亡史 记者 宋宇晟 最后一晚的"雕刻时光".宋宇晟 摄 "你好,我要一杯拿铁." 一切如常,没有排队,只是来喝 ...

  3. 安防市场规模超万亿 罗曼股份推智慧联动安防

    当各种车站暴恐事件.交通安全事故.市民人身伤害事件屡屡发生,"智能安防"在一系列热点安全事件中得到了极大的普及,"人脸识别"."一键报警"等 ...

  4. 罗曼股份抢先驶入四万亿智慧城市建设主航道

    远程云控制管理系统.智慧微枢纽-一系列新兴的智能业务勾勒出罗曼股份(430662.OC)从传统景观照明企业华丽转型智慧城市运营商的轮廓,抢先驶入当下智慧城市建设浪潮中的主航道. 行业专家认为,随着产业 ...

  5. 从轻盈奶茶到拉普山鲜奶茶,罗曼林实现品类突围

    提到罗曼林,很多人首先想到的就是手工冰淇淋.2019年,罗曼林在正定古城历史文化街开设了第一家门店,主打手工冰淇淋球,并将冰淇淋创新性的融入茶饮之中,推出冰淇淋晶钻莓莓.冰淇淋多肉葡萄等产品,备受市场 ...

  6. 红色警戒2:罗曼诺夫的复仇(openRA) Linux安装指南

    红色警戒2:罗曼诺夫的复仇 Linux安装指南 Red Alert 2: Romanov's Vengeance Linux安装指南 openRA 编译 游戏截图: -----方法1 AppImage ...

  7. 【生活】罗曼·罗兰语录

    罗曼·罗兰(Romain Rolland,1866年1月29日-1944年12月30日),1866年1月29日生于法国克拉姆西,思想家,文学家,批判现实主义作家,音乐评论家,社会活动家,1915年诺贝 ...

  8. 吴军《罗曼·罗兰 | 年轻时为什么需要理想主义?》

    文章目录 <巨人三传>给我很大的鼓舞 通过<约翰·克利斯朵夫>深入了解罗曼·罗兰所说的英雄主义 小结 <巨人三传>给我很大的鼓舞 这一讲,我们谈谈罗曼·罗兰.上一讲 ...

  9. 凝聚抗疫力量,罗曼林冰淇淋发放百万补贴助力门店复工复产

    阳春三月,马上就要进入新茶饮的消费旺季,但突如其来的又一轮新冠肺炎疫情,让众多门店生意急转直下.3月9日,沧州全域启动全员核酸工作,罗曼林在沧州的所有门店均被关停,随即,罗曼林总公司表示给予沧州区域各 ...

最新文章

  1. 如何在游标里控制条件_热处理精密渗碳里的碳势如何控制
  2. 2011年9月最新整理的10个有趣的jQuery插件集合
  3. 一霎清明雨,实现考勤管理。
  4. 2、Keepalived提供日志与双主模型演示
  5. win10 下pycharm+anaconda 编译生成pyd文件
  6. 【.NET Core项目实战-统一认证平台】第十四章 授权篇-自定义授权方式
  7. android第二十步摄像
  8. CVPR2021开源项目,带你傲游宇宙!
  9. Function function 隐式function
  10. 网络编程----观察进程的启动与停止
  11. 使用Python批量转换图片格式
  12. C++一本通在线测评网站 题目1224
  13. python学习笔记(52周存钱挑战)
  14. 小程序转发功能(类似于美团红包转发功能)的简单实现
  15. 每天盯着桌面,送你几个4k、8k壁纸资源的网站,请收好
  16. 农村信用贷款要具备什么条件,有哪些要求
  17. 生成二维码与条形码的各种方法
  18. reactive和ref区别
  19. “联想笔记本电脑的电池显示0%,充不进电” 解决方案
  20. 请求分页管理方式页面置换算法

热门文章

  1. SCI、Ei投稿指南
  2. Python中groupby的简单使用
  3. leetcode - 376. 摆动序列
  4. heavy hitter是什么意思?
  5. matlab编程进行卡尔曼滤波的简单例子
  6. matlab计算曲线形心,并将y轴移动到形心上,使图形居中布置
  7. Python range() 函数用法
  8. FFmpeg命令的几种应用
  9. MySQL的用户密码过期功能详解
  10. 天池-新闻推荐-多路召回