codeforces 122C perfect team】的更多相关文章

You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematician. She/he can have no specialization, but can't have…
传送门 考虑如何保证限制,首先团队数最大就是 $min(c,m)$ 但是还不够,每个团队还要 $3$ 个人,所以还要和 $(c+m+x)/3$ 再取 $min$ 这样就满足所有限制了 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll;…
链接: https://codeforces.com/contest/1221/problem/C 题意: You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematici…
原文链接https://www.cnblogs.com/zhouzhendong/p/9161557.html 题目传送门 - Codeforces 986D 题意 给定一个数 $n(n\leq 10^{1500000})$ , 求满足 $(\prod b_i)\geq n$ 的 $\min(\sum b_i)$ . 题解 这题是下面链接中那题的加强版. BZOJ1263 [SCOI2006]整数划分 高精度 这题的做法是预估出大概有多少个 $3$ ,然后最后几个数一个一个加上去就可以了. 至于…
原文链接https://www.cnblogs.com/zhouzhendong/p/9074164.html 题目传送门 - Codeforces 980D 题意 $\rm Codeforces$ 真是个令人伤心的地方. 伤心的 $zzd$ 现在给你一个含有 $n$ 个数字元素的数列. $zzd$ 问你对于 $1$ 到 $n$ 之间的每一个 $k$ 满足 $Q(序列)=k$ 的原序列的连续子序列个数. 其中,$Q()$定义如下: 把当前数列中的数分组,使得同组中任意两个数的乘积为完全平方数.其…
题目链接:http://codeforces.com/problemset/problem/919/B AC代码: #include<cstdio> using namespace std; //对全局变量或者对于一个或多个函数来说是全局的变量的时候,要注意上次用完该变量后变量的值,看其是否需要进行初始化. int main() { int k, index = 1, stemp, s = 19; int arr[10005]; int sum = 0; while (scanf("…
题目链接:Perfect Security 题意:给出N个数代表密码,再给出N个数代表key.现在要将key组排序,使key组和密码组的亦或所形成的组字典序最小. 题解:要使密码组里面每个数都找到能使其亦或和最小的数可以将key建成一棵字典树(这里建树方式很关键,可以每个数都从2^31开始建树,这样可以使我们在遍历树查询更加方便).之后再遍历密码组每次在字典树里面找到一个能使它亦或和最小的数,再将这个数从字典树中删掉...  字典树太久不写,很多东西都忘记了! #include<bits/std…
http://codeforces.com/contest/932/problem/E 题意:   可以看做 有n种小球,每种小球有无限个,先从中选出x种,再在这x种小球中任选k个小球的方案数 选出的x种不一样,任选k个球的顺序不一样 均视做不同的方案 f[i][j] 表示选了i个小球,来自j种的方案数 那么答案就是 考虑选的第i个球是否是选过的一种, f[i][j]=f[i-1][j]*j+f[i-1][j-1]*(n-(j-1)) #include<cstdio> #include<…
E. Team Work time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people fo…
A. Perfect Permutation time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output A permutation is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them…
Discription It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the oth…
C. Perfect Security time limit per test3.5 seconds memory limit per test512 megabytes inputstandard input outputstandard output Alice has a very important message M consisting of some non-negative integers that she wants to keep secret from Eve. Alic…
Perfect Security 题意:给你一个A[i]数组, 再给你一个B[i]数组, 现在用选取 B[i] 数组中的一个 去和 A[i] 数组里的一个元素去进行异或操作, B[i]数组的元素只能用一次,现在求A[i]数组异或后的最小字典序. 题解:将B[I]数组按照2进制分解之后开一个字典树, 然后匹配每个A[i]中的元素就好了. 代码: #include<bits/stdc++.h> using namespace std; #define LL long long #define UL…
D. Basketball Team time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GU…
题目链接:点击打开链接 题意: 给定n m h 表示有m个部门,有个人如今在部门h 以下m个数字表示每一个部门的人数.(包含他自己) 在这些人中随机挑选n个人,问挑出的人中存在和这个人同部门的概率是多少. 这个人一定在挑出的n个人中. 反向思考.答案是 1 - 不可能概率 不可能概率 = C(n-1, sum-1-a[h]) / C(n-1, sum-1) 发现2个组合数的分母部分同样,所以仅仅须要把2个组合数的分子部分相除就可以. #include <cstdio> #include <…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF1016G.html 题目传送门 - CF1016G 题意 给定 $n,x,y$ ,以及一个含有 $n$ 个元素的数组 $a$ . 我们称一个数对 $(i,j)$ 是合法的,当且仅当存在一个 $v$ ,使得 $\gcd(a_i,v)=x$ 且 ${\rm lcm} (a_j,v)=y$ . 请你统计有多少合法的 $(i,j)$ 数对. $n\leq 2\times 10^5,1\leq x,y,a_i\le…
<题目链接> 题目大意: 给定两个长度为n的序列,可以改变第二个序列中数的顺序,使得两个序列相同位置的数异或之后得到的新序列的字典序最小. 解题分析: 用01字典树来解决异或最值问题.因为是改变第二个序列的顺序,即按照第一个序列的顺序输出异或结果,所以我们将第二个序列建树.然后用第一个序列在树上进行查询.然后就是01字典树基本操作,因为每个数能够被使用一次,所以每个节点加上$num[N]$数组标记,并且加上del操作. #include <bits/stdc++.h> using…
题意: 有这样一个问题,给出一个数组,把里面的数字分组,使得每一个组里面的数两两相乘都是完全平方数. 问最少可以分成的组数k是多少. 现在一个人有一个数组,他想知道这个数组的连续子数组中,使得上面的问题答案分别为1到n的数组有多少个. 第一个样例 2 5 5 子数组有[5],[5],[5 5]三个,这三个组最少可以分别分为1 1 1组,使得每个组的任意两个数相乘都是平方数. 思路: 感谢js帮本智障debug. 首先对于一个不为0的数,如果把它的所有完全平方数的因子去掉,那么是不会影响结果的.…
传送门 01trie板子题. 给出两个数列,允许把第二个数列重新排列. 求使得两个数列每个位置对应的数的异或值和成为最小值的每个位置的异或和. 把第二个数列插入到01trie里面然后对于第一个数列中的数挨个询问最小异或和即可. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; const int N=3e5+5,P=30; int n,son[N*30][2],siz[N*30],a[N],tot=…
题意: 给定一个数n,选出m个数使得 $\Pi_{i=1}^m a_i\ge n$,求$\sum_{i=1}^m a_i$的最小值 ,其中$m$的大小不限 $n$的长度$\le 10^6$ 简单的计算可以发现 我们要尽量多的选$3$ 在最后特别逼近的时候 会有 $3^x\times2,3^x\times3,3^x\times4$三种选择 于是我们可以先求出一个逼近$n$的形如$3^x$的数$T$,之后暴力枚举三种情况,只要$T\ge n$则跳出 否则$T=T*3$继续枚举 对于一开始求出$T=3…
题目链接 Observations 含有 $n$ 个点且 key(以下也称 key 为「权值」)是 1 到 $n$ 的 BST 具有下列性质: 若 $k$ 是一个非根叶子且是个左儿子,则 $k$ 的父亲是 $k+1$ . 证明:假设 $k$ 的父亲是 $p$ 且 $p \ne k + 1$,则 $p > k + 1$:显然 $k + 1$ 不可能是 $k$ 的祖先. 设 $k$ 和 $k + 1$ 的最近公共祖先是 $t$,则有 $k < t < k + 1$ 或者 $ k + 1 &l…
题目链接 题意 : 其实就是要求 分析 : 先暴力将次方通过第二类斯特林数转化成下降幂 ( 套路?) 然后再一步步化简.使得最外层和 N 有关的 ∑ 划掉 这里有个技巧就是 将组合数的表达式放到一边.然后通过组合意义来化简 然后就可以 O( k ^ 2 ) 算出答案了 另外化到后面其实有种产生 这里可以用另外一种方式化简 考虑其组合意义 相当于先从 n 个数中挑出 i 个数.然后再从 i 个数中取 j 个进行排列 其他数可选可不选 具体可以看 Click here #include<bits/s…
题面传送门 题意:给出 \(n\),构造出序列 \(b_1,b_2,\dots,b_m\) 使得 \(\prod\limits_{i=1}^mb_i\geq n\),求 \(\sum\limits_{i=1}^mb_i\) 的最小值.\(\lg n\leq 1.5\times 10^6\) 被 hb 叫来写这题的题解 u1s1 这题实在是太恐怖了,以下是我的全部非 AC 提交: 首先直接做肯定是不太容易的. 容易发现答案具有单调性,故可以二分答案,本题转化为一个判定性问题. 我们要求:和为 \(…
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Finding Team Member codeforces 579C A Problem about Polyline codeforces 579D "Or" Game codeforces 579E Weakness and Poorness codeforces 579F LCS Aga…
传送门 A. 2048 Game 乱搞即可. Code #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() //#define Local using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 1e5…
唉,又是掉分的一场比赛... A. 2048 Game 题意:给出一个数组,问能不能通过一系列操作(将数组中的两个数相加变成另一个数),使得数组中包含2048,数组中的数全是2的指数,可以则输出YES 思路:只要有两个数比2048小且一样,则合并,直至不存在两个数一样且比2048小,之后看看数组中是否有2048即可. #include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; int v[maxn],arr[ma…
题解出处:https://www.luogu.org/problemnew/solution/CF1195C 很水的一道C题……目测难度在黄~绿左右.请各位切题者合理评分. 注意到可以选择的球员编号是严格递增的,因此可以把状态的第一维定义为球员编号,第二维描述编号同为 ii 的两名球员的选取情况. 定义状态:f[i][0/1/2]f[i][0/1/2] 表示选取了编号在 ii 及以前的球员,所能得到的身高总和最大值.其中,第二维的 00 表示编号为 ii 的球员一个都不选:11 表示只选上面一个…
                                                                                                             A. Drinks Choosing                                                                                                              time limit pe…
C. Basketball Exercise time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. 2⋅n2⋅…
[codeforces 317]A. Perfect Pair 试题描述 Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y a…