标签:too absolute wing problem ios val lis decided etc
题目链接: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 暴力
标签:too absolute wing problem ios val lis decided etc
原文地址:https://www.cnblogs.com/SaltyFishQF/p/10392847.html