Codeforces 949E Binary Cards】的更多相关文章

Description 给出一个长度为 \(n\) 的数组,求使得用最少数量的 \(2^k\) 或 \(-2^k\) 的数,使得数组中的每一个元素都可以被你选出的 \(2\) 的次幂表示 题面 Solution 注意到两个性质: 1.一个数不会用两次,举个例子:用两个 \(2\),不如用 \(2,4\) 范围广 2.一个数不会既用 \(2^k\) 又用 \(-2^k\),显然用 \(-2^k,2^{k+1}\) 或者 \(2^k,-2^{k+1}\) 更优 这样就可以依次考虑每一位了: 如果所有…
[CodeForces 1251B --- Binary Palindromes] Description A palindrome is a string t which reads the same backward as forward (formally, t[i]=t[|t|+1−i] for all i∈[1,|t|]). Here |t| denotes the length of a string t. For example, the strings 010, 1001 and…
B. Cards Sorting  http://codeforces.com/problemset/problem/830/B Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the sam…
CardsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/K Description You have N cards with different numbers on them. Your goal is to find a card with a maximal number. At the beginning a…
听说这是一道$ Tourist$现场没出的题 Codeforces #662C 题意: 给定$n*m的 01$矩阵,可以任意反转一行/列($0$变$1$,$1$变$0$),求最少$ 1$的数量 $ n<=20 \ m<=100000$ $ Solution$ 考虑暴力 枚举每一行反转/不反转 预处理$ g(s)$表示某状态为$ s$的列的最少$ 1$的数量 显然$ g(s)=min(popcount(s),n-popcount(s))$ 枚举每行是否反转之后直接$ O(m)$计算即可 时间复杂…
838A - Binary Blocks 思路:求一下前缀和,然后就能很快算出每一小正方块中1的个数了,0的个数等于k*k减去1的个数,两个的最小值就是要加进答案的值. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset((a),(b),sizeof(a)) const int INF=0x3f3f3f3f; ; ch…
  B. Cards   time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she…
题目链接: A. Cards 题意: 问两个数的和相同,怎么组合; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> using namespace std; #define For(i,j…
CardsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/K Description You have N cards with different numbers on them. Your goal is to find a card with a maximal number. At the beginning a…
题目链接:http://codeforces.com/contest/830/problem/B 题解:其实这题就是求当前大小的数到下一个大小的数直接有多少个数,这时候可以利用数据结构来查询它们之间有几个数优先往后面找如果后面没了再轮到前面找.可以开始将每个数的下表定为1然后拿掉之后就为0然后两值之间有几个数就用区间求和来求. #include <iostream> #include <cstring> #include <cstdio> #include <al…