D. Almost Difference time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let's denote a function You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) o…
Educational Codeforces Round 34 (Rated for Div. 2) A Hungry Student Problem 题目链接: http://codeforces.com/contest/903/problem/A 思路: 直接模拟 代码: #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); while(n--) { i…
D. Almost Difference Let's denote a function You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n. Input The first line contains one integer n (1 ≤ n ≤ 200000) — t…
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai. Mishka can put a box i into a…
B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome mons…
B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab. After two hours of playing the game Vova has tracked the monster and analyzed its tactics…
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/problem/A Description You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon…
地址:http://codeforces.com/contest/660/problem/B 题目: B. Seating On Bus time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider 2n rows of the seats in a bus. n rows of the seats on the left…
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some frie…
F - Clear The Matrix 分析 题目问将所有星变成点的花费,限制了行数(只有4行),就可以往状压DP上去靠了. \(dp[i][j]\) 表示到第 \(i\) 列时状态为 \(j\) 的花费,只需要记录 16 位二进制,因为我们最多只能影响到 4 * 4 的星,那么每次都是从一个 4 * 4 的矩阵转移到一个 4 * 4 的矩阵,注意,转移时必须保证最左边列全部为 1 (即都是星号),那么最后答案就是 \(dp[n][(1 << 16) - 1]\). 比如我们选定点 (i,…
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai. Mishka can put a box i into a…
#include<bits/stdc++.h>using namespace std;int n,x;int chess[17*17];//记录棋盘上的numberarray<int,2>pace[17*17*3][17*17*3],dp[17*17][3];//first记录root,second记录changearray<int,2>operator+(const array<int,2>a,const array<int,2> b){   …
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some frie…
E. Lomsat gelral Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/problem/E Description You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the sub…
You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist. Divisor of n is any such natural number, that n can be divided by it without remainder. Input The first line contains two integers n and k (1 ≤ n ≤ …
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 [代码]: #include<bits/stdc++.h> using namespace std; int main() { +]; int maxn,minn; maxn=minn=; cin>>n; ;i<=n;i++) { cin>>a[i]; } ;i&l…
Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/problem/A 题目给出的条件是 距离为曼哈顿距离,而曼哈顿距离等价于步长. 由题目的一半条件,可以得到步长和为AB步长,各自步长为AB步长的一半. 所以显然可以推出: \[1.如果和为奇数则,不存在\\ 2.如果都为偶数,显然只需要取步长一半即可\\ \] //原始代码 #include<bi…
Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. Water The Garden 题意:给你一个长度为\(n\)的池子,告诉你哪些地方一开始有水, 每秒可以向左和向右增加一格的水, 问什么时候全部充满水.(\(n \le 200\)) 题解:按题意模拟.每次进来一个水龙头,就更新所有点的答案 (取\(min\)).最 后把所有点取个\(max\)就…
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(…
Educational Codeforces Round 58 (Rated for Div. 2)  题目总链接:https://codeforces.com/contest/1101 A. Minimum Integer 题意: 多组数据,给你三个数l,r,d,要求在区间[l,r]之外找一个最小的x,使得x%d==0. 题解: 当d<l or d>r的时候,直接输出d就好了. 当l<=d<=r的时候,找到最小的t,使得t*d>r就行了. 具体操作见代码: #include…
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ 初始\([1,500000]\)都为0,后续有两种操作: ​ \(1\).将\(a[x]\)的值加上\(y\). ​ \(2\).求所有满足\(i\ mod\ x=y\)的\(a[i]\)的和. [Solution] ​ 具体做法就是,对于前\(\sqrt{500000}=708\)个数,定义\(…
Educational Codeforces Round 64 部分题解 不更了不更了 CF1156D 0-1-Tree 有一棵树,边权都是0或1.定义点对\(x,y(x\neq y)\)合法当且仅当树上\(x\)到\(y\)的路径权值是一段0接一段1.求合法点对数量. 直接点分治 我是傻逼居然还写了50min... https://codeforces.com/contest/1156/submission/53661175 CF1156E Special Segments of Permut…
/* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f(a, b) = 1 + f(a, b-gcd(a, b)); 求 f(a, b) , a,b <= 1e12 分析: b 每次减 gcd(a, b) 等价于 b/gcd(a,b) 每次减 1 减到什么时候呢,就是 b/gcd(a,b)-k 后 不与 a 互质 可先将 a 质因数分解,b能除就除,不能…
UPD:变色了!!!历史最高1618~ Educational Codeforces Round 81 (Rated for Div. 2) The 2019 University of Jordan Collegiate Programming Contest   充实的一天,打两场可还行.补的一些题记录一下. edu81 Educational Codeforces Round 81 (Rated for Div. 2) 还不知道上分还是掉分,还挺可惜的,被B卡了没做出来,C也调了一会儿答案…
Educational Codeforces Round 43  A. Minimum Binary Number 显然可以把所有\(1\)合并成一个 注意没有\(1\)的情况 view code //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std…
Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性要相同. 由求和公式得k个不同奇数组成的最小数为k2,所以n≥k2. #include <bits/stdc++.h> using namespace std; void solve(){ int n,k; cin>>n>>k; if((n-k)%2==0&&…
Educational Codeforces Round 129 (Rated for Div. 2) A-D A 题目 https://codeforces.com/contest/1681/problem/A 题解 思路 知识点:贪心. 先手的一方拥有大于等于对方最大牌的牌即可获胜,所以考虑取两组牌各自的最大值进行比较. 时间复杂度 \(O(n)\) 空间复杂度 \(O(1)\) 代码 #include <bits/stdc++.h> #define ll long long using…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R andx = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0. 输入 Th…
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. 输入 The only line contains odd integer n (1 ≤ n ≤ 49). 输出 Print n lines…