Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer \(n\) he can represent fraction \(\frac{2}{n}\) as a sum of three distinct posi…
题意:给定n,求三个不同的数满足,2/n = 1/x + 1/y + 1/z. 析:首先1是没有解的,然后其他解都可以这样来表示 1/n, 1/(n+1), 1/(n*(n+1)),这三个解. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <…
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct posit…
题目 构造一组 $x, y, z$,使得对于给定的 $n$,满足 $\frac{1}{x}  + \frac{1}{y} + \frac{1}{z} =  \frac{2}{n}$. 分析: 样例二已经暴露了此题的本质. 显然 $n, (n+1), n(n+1)$ 为一组合法解.特殊地,当 $n=1$ 时,无解,因为此时 $n+1$ 与 $n(n+1)$ 相等(也可以证明没有其他形式的解). #include<bits/stdc++.h> using namespace std; int n;…
codeforces 811E Vladik and Entertaining Flags 题面 \(n*m(1<=n<=10, 1<=m<=1e5)\)的棋盘,每个格子有一个值. 定义联通块:联通块中所有格子的值相等,并且格子四联通. \(1e5\)次询问,每次询问子矩形\((1, l, n, r)\)中联通块的数量. 题解 线段树区间合并. \(cnt[rt]\):区间中联通块个数 \(pre[rt][]\):在区间中用并查集维护端点的连通性.在给合并之后的集合重新编号时,要注…
传送门 Description Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction   as a sum of three distinct positive fractions in form . Help Vladik with that, i.e for a g…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as…
B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school found a kind of sorting called z-sort. The array a with n elements are z-sorted if two conditions hold: ai ≥ ai - 1 for all even i, ai ≤ ai - 1 for all…
题目链接:http://codeforces.com/contest/707/problem/C 题目大意:给你一条边,问你能否构造一个包含这条边的直角三角形且该直角三角形三条边都为整数,能则输出另外两条边,否则输出-1“”. 解题思路:下面是我从作业帮上找的- -, 利用平方差公式令斜边为c,直角边为a.b,且b为最短边c²-a²=(c+a)(c-a)因此(c+a)(c-a)是完全平方数,且(c-a)是(c+a)的一个因数1.如果(c-a)=1,则(c+a)是完全平方数(最短边是任意大于2的奇…
题目链接 https://codeforces.com/contest/1246/problem/D 题解 首先考虑答案的下界是\(n-1-dep\) (\(dep\)为树的深度,即任何点到根的最大边数),因为每一次操作只会使一个子树内的点深度\(-1\), 也就最多使得最大深度\(-1\). 那么这个下界能否达到呢?答案是肯定的,因为考虑将过程倒过来,每次选择一个子树将它沿某条边向下移动,对于任何一棵非链的树,最深点到根的路径上一定存在分叉,因此就一定可以通过移动使得最大深度\(+1\). 考…