Roman and Browser-罗曼的浏览器 CodeForce1100A 暴力

Posted saltyfishqf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Roman and Browser-罗曼的浏览器 CodeForce1100A 暴力相关的知识,希望对你有一定的参考价值。

题目链接: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 }

 

以上是关于Roman and Browser-罗曼的浏览器 CodeForce1100A 暴力的主要内容,如果未能解决你的问题,请参考以下文章

BROWSER COMPATIBILITY AND TRANSPILATION

CF401D Roman and Numbers

D. Roman and Numbers(状压dp)

CF401D Roman and Numbers

codeforces401D Roman and Numbers(数位状压dp)

Unity3d windows平台基于3D WebView for Windows and macOS (Web Browser)插件打开内嵌网页支持AR/VR功能实现