题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For example, cows exhibiting feature #1 might h…
P1360 [USACO07MAR]黄金阵容均衡Gold Balanced L… 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For ex…
P1360 [USACO07MAR]黄金阵容均衡Gold Balanced L… 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For ex…
https://www.luogu.org/problem/show?pid=1360 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For…
题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For example, cows exhibiting feature #1 might h…
传送门 真的骚的一个题,看了半天只会个前缀和+暴力.. 纯考思维.. 良心题解 #include <cstdio> #include <cstring> #include <algorithm> #define M 41 #define N 100011 #define max(x, y) ((x) > (y) ? (x) : (y)) int n, m, ans, last; struct node { int sum[M], id; node() { id =…
题目 不得不说这个题非常毒瘤. 简化题意 这个题的暴力还是非常好想的,完全可以过\(50\%\)的数据.但是\(100\%\)就很难想了. 因为数据很大,所以我们需要用\(O(\sqrt n)\)的时间求出每个时间的前面第一个跟它满足均衡区间的时间. 此时我们会很快速的想到\(Hash\)或\(Map\),他们的时间复杂度是小于\(O(\sqrt n)的\)所以满足要求,因此一般看到寻找相同得值的时候,最好还是想想怎么优化吧 \(Code\) #include <iostream> #incl…
[LuoguP1360][USACP07MAR]黄金阵容均衡(Link) 每天会增加一个数\(A\),将\(A\)二进制分解为\(a[i]\),对于每一个\(i\)都增加\(a[i]\),如果一段时间之内所有的位数上的数都增加了同一个数,那么成这个天数区间为均衡的.现在要求最长的均衡区间. 这道题很显然可以使用前缀和.我们统计每一天的前缀和为一个\(map\)数组\(A\).如果区间\([L, R]\)为均衡区间,那么\(A[R] - A[L - 1]\)就一定满足每一个二进制分解的位数都相等.…
###洛谷 P4999 题目链接 ### 题目大意:给你一个区间,求这段区间中所有数的,数位上的,数字之和. 分析: 这题与 洛谷 P2602 相似,稍微改一下就可以了. 求出 0 ~ 9 的个数,然后分别乘以 0 ~ 9 ,取模相加即可.要注意的是,在统计之和时,需要 加 mod 以保正答案正确,不然会 WA 两个点. 代码如下: #include<iostream> #include<algorithm> #include<string.h> using names…
题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For example, cows exhibiting feature #1 might h…