Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given kk sequences of integers. The length of the ii-th sequence equals to nini. You have to choose exactly two sequences…
ACM思维题训练集合 You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that: First we build by the array a an array s of partial sums, consisting of n elements. Element number…
ACM思维题训练集合 After passing a test, Vasya got himself a box of n candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself. This me…
ACM思维题训练集合 Desciption You've got an n × m pixel picture. Each pixel can be white or black. Your task is to change the colors of as few pixels as possible to obtain a barcode picture. A picture is a barcode if the following conditions are fulfilled: A…
题目地址:24道CF的DIv2 CD题有兴趣可以做一下. ACM思维题训练集合 Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He ha…
ACM思维题训练集合 A bracket sequence is a string, containing only characters "(", ")", "[" and "]". A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting…
ACM思维题训练集合 To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers…
ACM思维题训练集合 Furik and Rubik love playing computer games. Furik has recently found a new game that greatly interested Rubik. The game consists of n parts and to complete each part a player may probably need to complete some other ones. We know that the…
Nastya received a gift on New Year - a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month). Unfortunately, right a…
C. Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given kk sequences of integers. The length of the ii-th sequence equals to nini. You have to choose exactly two sequen…
[codeforces 509]C. Sums of Digits 试题描述 Vasya had a strictly increasing sequence of positive integers a1, ..., an. Vasya used it to build a new sequence b1, ..., bn, where bi is the sum of digits of ai's decimal representation. Then sequence ai got lo…
C. Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given kk sequences of integers. The length of the ii-th sequence equals to nini. You have to choose exactly two sequen…
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforces Round 26 题意: 设定数组 y = f(x) 使得 y[i] = sum(x[j]) (0 <= j < i) 求初始数组 A0 经过多少次 f(x) 后 会有一个元素 大于 k 分析: 考虑 A0 = {1, 0, 0, 0} A1 = {1, 1, 1, 1} -> {C(…
ACM思维题训练集合 You are given k sequences of integers. The length of the i-th sequence equals to ni. You have to choose exactly two sequences i and j (i≠j) such that you can remove exactly one element in each of them in such a way that the sum of the chan…
传送门 •题意 给k个数列,从中k个数列中找出任意2个数列 i ,j 使得数列i删除第x个数,和数列j删除第y个数的和相等 若存在,输出 i ,x 和 j,y •思路 每个数列之间的联系为数列的和之间的差det 如果开二维数组记录每个数列之间的det的话,显然是不可行的_(:з」∠)_ 这里用map<x ,pair<i ,j > >mp表示序列 i 删除第 j 个数后的总和为 x: 如果某两个序列各删除一个数,得到的总和相等, 也就是后一个序列得到的总和已存在(被前一个所记录)的话…
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 */ #include <cstdio> #include <algor…
E. Magic Stones time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Grigory has nn magic stones, conveniently numbered from 11 to nn . The charge of the ii -th stone is equal to cici . Sometime…
Prefix Sums 在 n >= 4时候直接暴力. n <= 4的时候二分加矩阵快速幂去check #include<bits/stdc++.h> #define LL long long #define LD long double #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #def…
题目链接 \(Description\) 给定\(n\)个数,每次可以将任意一个数乘上任意一个正整数. 求\(k\)次操作后,数列中数的种类最少可以是多少.对每个\(0\leq k\leq n\)输出答案. \(n\leq 3\times10^5,a_i\leq10^6\). \(Solution\) 有两种贪心策略,一是每次找一个出现次数最少的数,把它变成所有数的LCM:二是找一个出现次数最少,且它的某个倍数存在于原数列里的数,将它变成它的这个倍数. 对两种情况取\(\min\)即可. //9…
题目链接:https://codeforces.com/contest/978/problem/G 题目大意:n天m门考试,每门考试给定三个条件,分别为:1.可以开始复习的日期.2.考试日期.3.必须要复习的时间.根据以上条件,给出每天的安排,每天可以做三件事:1.考试.2.复习.3.休息 题解:先假设每天都在休息,然后依次填东西,策略是最先考试的最先复习 AC代码: #include<cstdio> #include<cstring> #include<algorithm&…
题目链接:https://codeforces.com/contest/978/problem/F 题目大意: n个程序员,k对仇家,每个程序员有一个能力值,当甲程序员的能力值绝对大于乙程序员的能力值时,甲可以做乙的爸爸,对于每个程序员,它可以做多少人的爸爸?(仇家之间不能做父子) 题解: 第一次:WA 失误 第二次:TL 找有效徒弟和仇家时,太复杂 第三次:ML 找有效徒弟依然复杂,找仇家简单了,但是内存超了 第四次:TL 解决了内存问题,找有效徒弟复杂,找仇家简单,时间超了(最接近成功的一次…
题目链接:https://codeforces.com/contest/978/problem/D 题解: 题目的大意就是:这组序列能否组成等差数列?一旦构成等差数列,等差数列的公差必定确定,而且,对于给定的数列,公差的可能性是已知的. 我的解决思路是:对于给定的数列,最后一位数 - 第一位数 / (n -1) 必定是公差,而对于我们要判断的原数列,其最后一位 - 第一位数的值是可以-2,-1,0,+1,+2的,穷举可能性一切公差,找出变动最小的情况.代码如下(有点小复杂,没优化): #incl…
C. Subset Sums time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a1, a2, ..., an and m sets S1, S2, ..., Sm of indices of elements of this array. Let's denote Sk = {Sk…
[题目链接]:http://codeforces.com/contest/509/problem/C [题意] 给你一个数组b[i] 要求一个严格升序的数组a[i]; 使得a[i]是b[i]各个位上的数的和; 并且a[n]最小; [题解] 每次处理的时候; 算出b[i]-b[i-1]的值 设为d 如果d>0 则从个位开始,不断地加1,直到d变成0; 如果个位变成9了,就加到十位,(这个时候个位的数字9不变,因为在低位,数字大一些,可以为后面高位的数字"分压",后面的数字就能小一些…
Partial Sums 题解: 一个数列多次前缀和之后, 对于第i个数来说他的答案就是 ; i <= n; ++i){ ; j <= i; ++j){ b[i] = (b[i] + 1ll * a[j] * C(k-+j-i,j-i)) % mod; } } 唯一注意的就是这个k会到1e9. 观察可能,其实我们最多也就用了n个组合数, 并且这个C(n, m) 的 m 足够小. 所以我们可以根据定义先把这几个组合数先预处理出来. 代码: #include<bits/stdc++.h>…
B.Equal Rectangles time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given 4…
题目链接:https://codeforces.com/problemset/problem/1197/D 题意: 给你一个序列,求一个子序列 a[l]~a[r] 使得该子序列的 sum(l,r)-k*(r-l+1)/m(向上取整)的值是在所有子序列中最大的,并输出最大值 思路: 法一:动态规划 dp[i][j] 表示序列到i截止,这一轮已经进行了j次取数(j = (len+m-1)%m) 那么dp[i][j]维护的就是起点为 s = i-j+1-m*t (t>=0)这个集合的最优,这样所有的…
ACM思维题训练集合 A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and &…
ACM思维题训练集合 C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As the boat drifts down the river, a wood full of blossoms shows up on the riverfront. "I've been here on…
ACM思维题训练集合 It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem. There are n displays placed along a road, and the i-th of them c…