cf的一次数学场... 递推 C 题意:长度<=n的数只含有7或8的个数 分析:每一位都有2种可能,累加不同长度的方案数就是总方案数 组合 G 题意:将5个苹果和3个梨放进n个不同的盒子里的方案数. 分析:经典的组合题目:C(n+5-1, 5) * C(n+3-1, 3).因为可以同一个盒子放多个苹果或梨,在n基础上多k-1个,看成每个盒子放一个. 组合 H 题意:将5个车放在n*n的棋盘上的方案数. 分析:也是经典的题目,先选行,再全排列,即C (n, 5) * A (n, 5). 枚举 I…
Description IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precisi…
Description The Department of economic development of IT City created a model of city development till year 2100. To prepare report about growth perspectives it is required to get growth estimates from the model. To get the growth estimates it is req…
Description IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when…
Description One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate e…
Description After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might & Magic". A part of t…
Description The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers. Lucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office g…
Description The city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time. Moore's law is the observation that…
Description The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. "Do I give such a hard task?" — the HR manager thought. "Just raise number 5 to the power of n and get last two dig…
题目链接:http://codeforces.com/contest/630/problem/K K. Indivisibility time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output IT City company developing computer games decided to upgrade its way to…
这题调得我心疲力竭...Educational Round 5就过一段时间再发了_(:з」∠)_ 先后找了三份AC代码对拍,结果有两份都会在某些数据上出点问题...这场的数据有点水啊_(:з」∠)_[然而卡掉本弱还是轻轻松松的] 题目链接:616F - Expensive Strings 题目大意:给出\(n\)个字符串\(t_i\)以及\(n\)个数\(c_i\),定义\(p_{s,i}\)为字符串\(s\)在\(t_i\)中出现的次数,\(f(s)=\sum_{i=1}^{n}c_i\cdo…
这题本来是想放在educational round 3的题解里的,但觉得很有意思就单独拿出来写了 题目链接:609E - Minimum spanning tree for each edge 题目大意:n个点,m条边,对每条边,询问包含此边的最小生成树的边权之和 题解:大部分人都是用LCA写的,这里提供一个更为精妙的做法. 模拟Kruskal算法建MST的过程,先将m条边按边权排序,依次进行判断.若点对(u,v)属于同一个连通块,则加入边{u,v,w}后会形成一个环,把环中最大的边换成w会多产…
题目链接   Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) #define MP make_pair #de…
CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students​ 依题意模拟即可 #include<bits/stdc++.h> using namespace std; int T; int n, x, a, b; int main() { cin >> T; while(T--) { cin >> n >> x >> a >> b; if(a > b) swap(a, b…
幸好我没有打这场,我VP的时候在C题就卡死了,我果然还是太菜了. A Vasya and Chocolate 题意:一个巧克力\(c\)元,买\(a\)赠\(b\),一共有\(n\)元,问能买几个巧克力. 小学数学题. B Vasya and Isolated Vertices 题意:\(n\)个点\(m\)条边的无向简单图最多和最少有几个不和任意点联通的点. 最少很好算,让每条边连接两个独立的点,答案就是\(n-2m\). 最多的话,就是让联通的点尽量组成完全图,这样消耗的边数最多,枚举有几个…
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20min 我说这句话,肯定是有原因的,我们看到 \(\operatorname{lcm}\) 会想到之前一些题:题目,我的题解 自然就往 \(a\times b=\operatorname{gcd}(a,b)\times \operatorname{lcm}(a,b)\) 的方向思考,但是,这太麻烦了,…
这题拖了快一周_(:з」∠)_就把这货单独拿出来溜溜吧~ 本文归属:Educational Codeforces Round 3 题目链接:609F - Frogs and mosquitoes 题目大意:在\(x\)轴上有\(n\)只青蛙,每只青蛙有对应的位置\(x_i\)和他舌头的长度\(t_i\),青蛙可以吃到位置在\([x_i,t_i]\)内的蚊子.\(m\)只蚊子依次降落在位置\(p_i\)上,如果这只蚊子在某只青蛙的攻击范围内,那么他会被这只青蛙吃掉,若有多只青蛙可以吃掉这只蚊子,处…
Codeforces Round 1132 这场比赛做了\(A\).\(B\).\(C\).\(F\)四题,排名\(89\). \(A\)题\(wa\)了一次,少考虑了一种情况 \(D\)题最后做出来,但被\(hack\)了...被\(hack\)的原因是没有想到答案会超过\(10^{12}\)(毕竟这个时间上的优化也是在最后迫不得已的情况下加的,就没有考虑正确性... Codeforces 1132 C 题意:给一些区间\([l_i,r_i]\),从中删掉两个,求剩下的区间最多能够覆盖的格子数…
Codeforces Round 1117 这场比赛做了\(A\).\(B\).\(C\).\(D\).\(E\),\(div.2\)排名\(31\),加上\(div.1\)排名\(64\). 主要是\(A\)题卡了很久,直到第\(52\)分钟才做出来,思路固化了,一直没想到最大平均值的区间就是只含有最大值的区间.幸好节奏没有受到太大影响. 最后去肝\(G\),最后一分钟一把过了样例,就赶紧交,结果\(ce\)了...实在是...是因为我定义重数组,而条件编译使我看不出有问题(这段快读的代码本机…
D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to cho…
A题Maximum Increase 大水题.最长连续递增子序列有多长. #include <cstdio> #include <algorithm> using namespace std; int main() { , len = , ans = ; scanf("%d",&n); ; i < n; i++) { scanf("%d", &a); if(a > rec) { rec = a, len++; }…
写了3小时 = =.这两天堕落了,昨天也刷了一晚上hihocoder比赛,还爆了零.之后得节制点了,好好准备考研.. 首先很容易想到 压缩数据 + 线段树 然后对于Pushdown真很难写..需要牵涉到状态修改(所以我又写了一个adjust函数,辅助修改) 我一直跪在test7,因为3号修改在一开始就会出现cover符号的修改,我一开始没有加(比方说1-4都是0,现在 做3 1 4,直接吧1-4的状态改为1就行了) #include <cstdio> #include <cstdlib&…
题目连接:678F - Lena and Queries 题目大意:给出两个树\(S,T\),问\(S\)中有多少连通子图与\(T\)同构.\(|S|\leq 1000,|T|\leq 12\) 题解:考虑树的最小表示法(有关知识可戳https://www.byvoid.com/zhs/blog/directed-tree-bracket-sequence),求出\(T\)以不同点为根时所有的子树状态 开始对树\(S\)进行\(DFS\),求出每个点的状态为\(t\)时的方案数,由于\(t\)还…
题目连接:678F - Lena and Queries 题目大意:要求对一个点集实现二维点对的插入,删除,以及询问\(q\):求\(max(x\cdot q+y)\) 题解:对每个点集内的点\(P(x_0,y_0)\),作过点\(P\)且斜率为\(-q\)的直线\(l\),则有\(l:y-y_0=-q(x-x_0)\),可以发现当\(x=0\)时,有\(y=q\cdot x_0+y_0\).因此只要找到一个点,使得过此点作斜率为\(-q\)的直线在\(y\)轴上的截距最大即可.可以发现满足条件…
题目连接:652F - Ants on a Circle 题目大意:\(n\)个蚂蚁在一个大小为\(m\)的圆上,每个蚂蚁有他的初始位置及初始面向,每个单位时间蚂蚁会朝着当前面向移动一个单位长度,在遇到其它蚂蚁时会立刻掉头.求经过\(t\)个单位时间后每一个蚂蚁的所在位置 题解:首先可以发现,最终答案其实是在不考虑碰撞下得出答案的一个排列,而且蚂蚁们的相对位置是不会改变的.所以如果求出了其中任意一个蚂蚁的位置,就能求出最终的答案. 为了方便起见,先默认所有蚂蚁的位置是按升序排的,且第一个蚂蚁的位…
咸鱼了好久...出来冒个泡_(:з」∠)_ 题目连接:1107G - Vasya and Maximum Profit 题目大意:给出\(n,a\)以及长度为\(n\)的数组\(c_i\)和长度为\(n\)的严格单调上升数组\(d_i\),求\(\max\limits_{1 \le l \le r \le n} (a\cdot(r-l+1)-\sum_{i=l}^{r}c_i-gap(l,r))\),其中\(gap(l, r) = \max\limits_{l \le i < r} (d_{i…
http://codeforces.com/contest/1073/problem/C   题意:给你长度为n的字符串,每个字符为L, R, U, D.给你终点位置(x, y).你每次出发的起点为(0, 0).你可以改动每次的移动方向到达(x,y)点.求改动的MaxID-MinID+1是多少. 思路: 先分别求x轴,y轴上的前缀和,偏于之后判断区间是否满足条件.详细见代码. 固定左端点,二分枚举右端点.判断左右端点的区间是否能够达成目标(区间长度是否大于未完成量,奇偶性是否相同) 注意点: s…
Solved   CodeForces 920A Water The Garden   Solved   CodeForces 920B Tea Queue   Solved   CodeForces 920C Swap Adjacent Elements       CodeForces 920D Tanks       CodeForces 920E Connected Components?       CodeForces 920F SUM and REPLACE       CodeF…
Ediv2 58 随手AK.jpg D 裸的虚树,在这里就不写了 E 傻逼贪心?这个题过的比$B$都多.jpg #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <cstdlib> #include <queue> #include <iostream> #include <bitset> us…
这场出题人好像特别喜欢998244353,每个题里都放一个 A.Find Divisible 考察选手对输入输出的掌握 输出l 2*l即可(为啥你要放这个题,凑字数吗 #include<cstdio> int n,l,r; int main() { scanf("%d",&n); ;i<=n;i++) { scanf("%d%d",&l,&r); printf(*l); } ; } B.Substring Removal 一…