VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects ai publications. The latest A/B test sug…
C. Restoring Permutation time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given a sequence b1,b2,-,bn. Find the lexicographically minimal permutation a1,a2,-,a2n such that bi=min(a2i−1,a…
After a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are n crossroads in the line in the town, and there is either the bus or the tram station at each crossroad. The crossroads…
讨论坏点的左右上下的矩形大小. #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, x, y; cin >> a >> b >> x >> y; // cout<<a<<" "<<b<<" "…
题意:给你一个\(01\)串,需要将所有的\(1\)给炸掉,每次炸都可以将一整个\(1\)的联通块炸掉,每炸一次消耗\(a\),可以将\(0\)转化为\(1\),消耗\(b\),问将所有\(1\)都炸掉的最小花费. 题解:贪心,如果\(1\)存在,那么我们至少要炸一次,然后可以枚举统计两个连通块之间的\(0\)的个数,判断是将这些\(0\)变为\(1\)然后炸一次的花费小,还是炸掉\(2\)个连通块的花费小,思路就是这样,具体实现见代码. 代码: int t; int a,b; string s…
题意:给你一个正整数\(n\),在\([1,4n]\)中找出\(n\)个数,使得这\(n\)个数中的任意两个数不互质且不能两两整除. 题解:这题我是找的规律,从\(4n\)开始,往前取\(n\)个偶数就好了. 代码: int t; int n; int cnt; int main() { ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin>>t; while(t--){ cin>>n; cnt=0; for(int i=4…
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and Big Brother 题意:我也没看太清,就是给你两个10以内的数a,b.a每天乘以3,b每天乘以2,求多少天后a大于b. 思路:应该是有公式的,不过看到数据这么小直接暴力乘求解.官方题解貌似就是这样,数据小就是水题. const int N=1e3+10; int main() { int a…
A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Tonio has a keyboard with only two letters, "V" and "K". One day, he has typed out a string s with only t…
A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后check就好. #include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int ans = 0; for(int i=0;i<s.size();i++){ if(s[i]=='V'){…
C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should s…
B. Bear and Friendship Condition 题目连接: http://codeforces.com/contest/791/problem/B Description Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pic…
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Tonio has a keyboard with only two letters, "V" and "K". One day, he has typed out a string s with only t…
地址:http://codeforces.com/contest/801/problem/D 题目: D. Volatile Kite time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a convex polygon P with n distinct vertices p1, p2, ..., p…
地址:http://codeforces.com/contest/801/problem/C 题目: C. Voltage Keepsake time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have n devices that you want to use simultaneously. The i-th devi…
B. Weakened Common Divisor time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mat…
Description Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to re…
http://codeforces.com/contest/948/problem/A A. Protect Sheep Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his she…